From a8ab845cd230517ca46f4cd5e67bc984de873ed5 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 18 Jun 2025 20:13:16 -0400 Subject: [PATCH] docs: Minor usage cleanup. --- docs/usage.md | 70 +++++++++++++++++++++++++++++++++++++-------------- src/main.c | 66 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 98 insertions(+), 38 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index a19bad88..ea43d022 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -7,8 +7,8 @@ Usage: out/debug/tildefriends command [command-options] commands: run - Run tildefriends (default). sandbox - Run a sandboxed tildefriends sandbox process (used internally). - import - Import apps to SSB. - export - Export apps from SSB. + import - Import apps from file to the database. + export - Export apps from the database to file. publish - Append a message to a feed. private - Append a private post message to a feed. create_invite - Create an invite. @@ -27,9 +27,11 @@ commands: ``` -out/debug/tildefriends run [options] +Usage: out/debug/tildefriends run [options] -options +Run tildefriends (default). + +options: -s, --script script Script to run (default: core/core.js). -d, --db-path path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). -k, --ssb-network-key key SSB network key to use. @@ -71,6 +73,8 @@ options Usage: out/debug/tildefriends sandbox [options] +Run a sandboxed tildefriends sandbox process (used internally). + options: -h, --help Show this usage information. -f, --fd File descriptor with which to communicate with parent process. @@ -80,7 +84,9 @@ options: ``` -out/debug/tildefriends import [options] [paths...] +Usage: out/debug/tildefriends import [options] [paths...] + +Import apps from file to the database. options: -u, --user user User into whose account apps will be imported (default: "import"). @@ -92,7 +98,9 @@ options: ``` -out/debug/tildefriends export [options] [paths...] +Usage: out/debug/tildefriends export [options] [paths...] + +Export apps from the database to file. options: -u, --user user User from whose account apps will be exported (default: "core"). @@ -106,7 +114,9 @@ paths Paths of apps to export (example: /~core/ssb /~user/a ``` -out/debug/tildefriends publish [options] +Usage: out/debug/tildefriends publish [options] + +Append a message to a feed. options: -u, --user user User owning identity with which to publish. @@ -120,7 +130,9 @@ options: ``` -out/debug/tildefriends private [options] +Usage: out/debug/tildefriends private [options] + +Append a private post message to a feed. options: -u, --user user User owning identity with which to publish (optional). @@ -135,7 +147,9 @@ options: ``` -out/debug/tildefriends create_invite [options] +Usage: out/debug/tildefriends create_invite [options] + +Create an invite. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -151,7 +165,9 @@ options: ``` -out/debug/tildefriends get_sequence [options] +Usage: out/debug/tildefriends get_sequence [options] + +Get the last sequence number for a feed. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -163,7 +179,9 @@ options: ``` -out/debug/tildefriends get_identity [options] +Usage: out/debug/tildefriends get_identity [options] + +Get the server account identity. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -174,7 +192,9 @@ options: ``` -out/debug/tildefriends get_profile [options] +Usage: out/debug/tildefriends get_profile [options] + +Get profile information for the given identity. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -186,7 +206,9 @@ options: ``` -out/debug/tildefriends get_contacts [options] +Usage: out/debug/tildefriends get_contacts [options] + +Get information about followed, blocked, and friend identities. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -198,7 +220,9 @@ options: ``` -out/debug/tildefriends has_blob [options] +Usage: out/debug/tildefriends has_blob [options] + +Check whether a blob is in the blob store. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -210,7 +234,9 @@ options: ``` -out/debug/tildefriends get_blob [options] +Usage: out/debug/tildefriends get_blob [options] + +Read a file from the blob store. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -223,7 +249,9 @@ options: ``` -out/debug/tildefriends store_blob [options] +Usage: out/debug/tildefriends store_blob [options] + +Write a file to the blob store. options: -d, --db-path db_path SQLite database path (default: /home/cory/.local/share/tildefriends/db.sqlite). @@ -235,7 +263,9 @@ options: ``` -out/debug/tildefriends verify [options] +Usage: out/debug/tildefriends verify [options] + +Verify a feed. options: -i, --identity identity Identity to verify. @@ -248,9 +278,11 @@ options: ``` -out/debug/tildefriends test [options] +Usage: out/debug/tildefriends test [options] -options +Test SSB. + +options: -t, --tests tests Comma-separated list of tests to run. (default: all) -h, --help Show this usage information. ``` diff --git a/src/main.c b/src/main.c index cb2b0e41..a6eb0bc0 100644 --- a/src/main.c +++ b/src/main.c @@ -169,8 +169,8 @@ typedef struct _command_t const command_t k_commands[] = { { "run", _tf_command_run, "Run tildefriends (default)." }, { "sandbox", _tf_command_sandbox, "Run a sandboxed tildefriends sandbox process (used internally)." }, - { "import", _tf_command_import, "Import apps to SSB." }, - { "export", _tf_command_export, "Export apps from SSB." }, + { "import", _tf_command_import, "Import apps from file to the database." }, + { "export", _tf_command_export, "Export apps from the database to file." }, { "publish", _tf_command_publish, "Append a message to a feed." }, { "private", _tf_command_private, "Append a private post message to a feed." }, { "create_invite", _tf_command_create_invite, "Create an invite." }, @@ -185,6 +185,18 @@ const command_t k_commands[] = { { "test", _tf_command_test, "Test SSB." }, }; +static const char* _description(const char* name) +{ + for (int i = 0; i < tf_countof(k_commands); i++) + { + if (strcmp(name, k_commands[i].name) == 0) + { + return k_commands[i].description; + } + } + return NULL; +} + static int _tf_command_test(const char* file, int argc, char* argv[]) { #if !defined(__ANDROID__) @@ -233,8 +245,9 @@ static int _tf_command_test(const char* file, int argc, char* argv[]) if (show_usage) { - tf_printf("\n%s test [options]\n\n", file); - tf_printf("options\n"); + tf_printf("\nUsage: %s test [options]\n\n", file); + tf_printf("%s\n\n", _description("test")); + tf_printf("options:\n"); tf_printf(" -t, --tests tests Comma-separated list of tests to run. (default: all)\n"); tf_printf(" -h, --help Show this usage information.\n"); tf_free((void*)default_db_path); @@ -288,7 +301,8 @@ static int _tf_command_import(const char* file, int argc, char* argv[]) if (show_usage) { - tf_printf("\n%s import [options] [paths...]\n\n", file); + tf_printf("\nUsage: %s import [options] [paths...]\n\n", file); + tf_printf("%s\n\n", _description("import")); tf_printf("options:\n"); tf_printf(" -u, --user user User into whose account apps will be imported (default: \"import\").\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); @@ -357,7 +371,8 @@ static int _tf_command_export(const char* file, int argc, char* argv[]) if (show_usage) { - tf_printf("\n%s export [options] [paths...]\n\n", file); + tf_printf("\nUsage: %s export [options] [paths...]\n\n", file); + tf_printf("%s\n\n", _description("export")); tf_printf("options:\n"); tf_printf(" -u, --user user User from whose account apps will be exported (default: \"core\").\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); @@ -473,7 +488,8 @@ static int _tf_command_publish(const char* file, int argc, char* argv[]) if (show_usage || !identity || !content) { - tf_printf("\n%s publish [options]\n\n", file); + tf_printf("\nUsage: %s publish [options]\n\n", file); + tf_printf("%s\n\n", _description("publish")); tf_printf("options:\n"); tf_printf(" -u, --user user User owning identity with which to publish.\n"); tf_printf(" -i, --id identity Identity with which to publish message.\n"); @@ -592,7 +608,8 @@ static int _tf_command_private(const char* file, int argc, char* argv[]) if (show_usage || !identity || !recipients || !text) { - tf_printf("\n%s private [options]\n\n", file); + tf_printf("\nUsage: %s private [options]\n\n", file); + tf_printf("%s\n\n", _description("private")); tf_printf("options:\n"); tf_printf(" -u, --user user User owning identity with which to publish (optional).\n"); tf_printf(" -i, --id identity Identity with which to publish message.\n"); @@ -723,7 +740,8 @@ static int _tf_command_store_blob(const char* file, int argc, char* argv[]) if (show_usage || !file_path) { - tf_printf("\n%s store_blob [options]\n\n", file); + tf_printf("\nUsage: %s store_blob [options]\n\n", file); + tf_printf("%s\n\n", _description("store_blob")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -f, --file file_path Path to file to add to the blob store.\n"); @@ -825,7 +843,8 @@ static int _tf_command_get_blob(const char* file, int argc, char* argv[]) if (show_usage || !blob_id) { - tf_printf("\n%s get_blob [options]\n\n", file); + tf_printf("\nUsage: %s get_blob [options]\n\n", file); + tf_printf("%s\n\n", _description("get_blob")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -b, --blob blob_id Blob identifier to retrieve.\n"); @@ -927,7 +946,8 @@ static int _tf_command_has_blob(const char* file, int argc, char* argv[]) if (show_usage || !blob_id) { - tf_printf("\n%s has_blob [options]\n\n", file); + tf_printf("\nUsage: %s has_blob [options]\n\n", file); + tf_printf("%s\n\n", _description("has_blob")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -b, --blob_id blob_id ID of blob to query.\n"); @@ -1005,7 +1025,8 @@ static int _tf_command_create_invite(const char* file, int argc, char* argv[]) if (show_usage || !identity || !use_count || !expires || !host || !port) { - tf_printf("\n%s create_invite [options]\n\n", file); + tf_printf("\nUsage: %s create_invite [options]\n\n", file); + tf_printf("%s\n\n", _description("create_invite")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -i, --identity identity Account from which to get latest sequence number.\n"); @@ -1073,7 +1094,8 @@ static int _tf_command_get_sequence(const char* file, int argc, char* argv[]) if (show_usage || !identity) { - tf_printf("\n%s get_sequence [options]\n\n", file); + tf_printf("\nUsage: %s get_sequence [options]\n\n", file); + tf_printf("%s\n\n", _description("get_sequence")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -i, --identity identity Account from which to get latest sequence number.\n"); @@ -1126,7 +1148,8 @@ static int _tf_command_get_identity(const char* file, int argc, char* argv[]) if (show_usage) { - tf_printf("\n%s get_identity [options]\n\n", file); + tf_printf("\nUsage: %s get_identity [options]\n\n", file); + tf_printf("%s\n\n", _description("get_identity")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -h, --help Show this usage information.\n"); @@ -1183,7 +1206,8 @@ static int _tf_command_get_profile(const char* file, int argc, char* argv[]) if (show_usage || !identity) { - tf_printf("\n%s get_profile [options]\n\n", file); + tf_printf("\nUsage: %s get_profile [options]\n\n", file); + tf_printf("%s\n\n", _description("get_profile")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -i, --identity identity Account for which to get profile information.\n"); @@ -1242,7 +1266,8 @@ static int _tf_command_get_contacts(const char* file, int argc, char* argv[]) if (show_usage || !identity) { - tf_printf("\n%s get_contacts [options]\n\n", file); + tf_printf("\nUsage: %s get_contacts [options]\n\n", file); + tf_printf("%s\n\n", _description("get_contacts")); tf_printf("options:\n"); tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -i, --identity identity Account from which to get contact information.\n"); @@ -1343,7 +1368,8 @@ static int _tf_command_verify(const char* file, int argc, char* argv[]) if (show_usage) { - tf_printf("\n%s verify [options]\n\n", file); + tf_printf("\nUsage: %s verify [options]\n\n", file); + tf_printf("%s\n\n", _description("verify")); tf_printf("options:\n"); tf_printf(" -i, --identity identity Identity to verify.\n"); tf_printf(" -s, --sequence sequence Sequence number to debug.\n"); @@ -1671,8 +1697,9 @@ static int _tf_command_run(const char* file, int argc, char* argv[]) if (show_usage) { - tf_printf("\n%s run [options]\n\n", file); - tf_printf("options\n"); + tf_printf("\nUsage: %s run [options]\n\n", file); + tf_printf("%s\n\n", _description("run")); + tf_printf("options:\n"); tf_printf(" -s, --script script Script to run (default: core/core.js).\n"); tf_printf(" -d, --db-path path SQLite database path (default: %s).\n", default_db_path); tf_printf(" -k, --ssb-network-key key SSB network key to use.\n"); @@ -1757,6 +1784,7 @@ static int _tf_command_sandbox(const char* file, int argc, char* argv[]) if (show_usage) { tf_printf("\nUsage: %s sandbox [options]\n\n", file); + tf_printf("%s\n\n", _description("sandbox")); tf_printf("options:\n"); tf_printf(" -h, --help Show this usage information.\n"); tf_printf(" -f, --fd File descriptor with which to communicate with parent process.\n");