ssb: Suppress noisy output when running command-line actions with output intended to be parsed.

This commit is contained in:
2025-01-14 21:37:11 -05:00
parent 56c77c781a
commit 250933bf41
7 changed files with 79 additions and 27 deletions

View File

@ -287,6 +287,7 @@ static int _tf_command_import(const char* file, int argc, char* argv[])
_create_directories_for_file(db_path, 0700);
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
if (optind < argc)
{
for (int i = optind; i < argc; i++)
@ -356,6 +357,7 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
}
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
if (optind < argc)
{
for (int i = optind; i < argc; i++)
@ -474,6 +476,7 @@ static int _tf_command_publish(const char* file, int argc, char* argv[])
tf_printf("Posting %s as account %s belonging to %s...\n", content, identity, user);
_create_directories_for_file(db_path, 0700);
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
uint8_t private_key[512] = { 0 };
if (tf_ssb_db_identity_get_private_key(ssb, user, identity, private_key, sizeof(private_key)))
{
@ -579,6 +582,7 @@ static int _tf_command_private(const char* file, int argc, char* argv[])
tf_printf("Posting %s as account %s belonging to %s...\n", text, identity, user);
_create_directories_for_file(db_path, 0700);
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
uint8_t private_key[512] = { 0 };
const char* recipient_list[k_max_private_message_recipients] = { 0 };
int recipient_count = 0;
@ -728,6 +732,7 @@ static int _tf_command_store_blob(const char* file, int argc, char* argv[])
char id[256];
_create_directories_for_file(db_path, 0700);
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
if (tf_ssb_db_blob_store(ssb, (const uint8_t*)data, size, id, sizeof(id), NULL))
{
tf_printf("%s\n", id);
@ -845,6 +850,7 @@ static int _tf_command_get_sequence(const char* file, int argc, char* argv[])
}
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
int64_t sequence = -1;
int result = tf_ssb_db_get_latest_message_by_author(ssb, identity, &sequence, NULL, 0) ? EXIT_SUCCESS : EXIT_FAILURE;
tf_printf("%" PRId64 "\n", sequence);
@ -897,6 +903,7 @@ static int _tf_command_get_identity(const char* file, int argc, char* argv[])
char id[k_id_base64_len] = { 0 };
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
int result = tf_ssb_whoami(ssb, id, sizeof(id)) ? EXIT_SUCCESS : EXIT_FAILURE;
tf_printf("%s\n", id);
tf_ssb_destroy(ssb);
@ -1012,6 +1019,7 @@ static int _tf_command_get_contacts(const char* file, int argc, char* argv[])
}
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
JSContext* context = tf_ssb_get_context(ssb);
JSValue contacts = JS_NewObject(context);
JSValue follows = JS_NewObject(context);