From d8a1d3a90812a4de59b1237dfad8a2cbe0181268 Mon Sep 17 00:00:00 2001 From: Muggle Wei Date: Sun, 3 Sep 2023 23:33:32 +0800 Subject: [PATCH 1/3] update delete command usage --- src/yoauth/exe/command_del.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yoauth/exe/command_del.c b/src/yoauth/exe/command_del.c index 7d63903..bf8ca77 100644 --- a/src/yoauth/exe/command_del.c +++ b/src/yoauth/exe/command_del.c @@ -13,7 +13,7 @@ void yoauth_usage_command_del() YOAUTH_OUTPUT(""); YOAUTH_TIP("e.g."); - YOAUTH_OUTPUT_KV("yoauth delete -d github", + YOAUTH_OUTPUT_KV("yoauth delete -a github", "//!< delte account 'github'", 40); } From e2090ca45ccb3cacaac242119fa700446c349bf4 Mon Sep 17 00:00:00 2001 From: Muggle Wei Date: Sun, 3 Sep 2023 23:40:13 +0800 Subject: [PATCH 2/3] support help in subcommand --- src/yoauth/exe/command_add.c | 9 +++++++-- src/yoauth/exe/command_del.c | 11 ++++++++--- src/yoauth/exe/command_dump.c | 7 ++++++- src/yoauth/exe/command_list.c | 7 ++++++- src/yoauth/exe/command_load.c | 7 ++++++- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/yoauth/exe/command_add.c b/src/yoauth/exe/command_add.c index 6c4ceec..8631ec3 100644 --- a/src/yoauth/exe/command_add.c +++ b/src/yoauth/exe/command_add.c @@ -15,7 +15,7 @@ void yoauth_usage_command_add() YOAUTH_OUTPUT(""); YOAUTH_TIP("e.g."); YOAUTH_OUTPUT_KV("yoauth add -a github -k NBSWY3DPO5XXE3DE", - "//!< save secret key for account 'github'", 40); + "//!< save secret key for account 'github'", 43); } typedef struct cmd_add_args { @@ -31,6 +31,7 @@ static bool yoauth_parse_args_command_add(int argc, char **argv, { "user", required_argument, NULL, 'u' }, { "account", required_argument, NULL, 'a' }, { "key", required_argument, NULL, 'k' }, + { "help", required_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; @@ -39,7 +40,7 @@ static bool yoauth_parse_args_command_add(int argc, char **argv, while (true) { int c = 0; int option_index = 0; - c = getopt_long(argc, argv, "u:a:k:", long_options, &option_index); + c = getopt_long(argc, argv, "u:a:k:h", long_options, &option_index); if (c == -1) { break; } @@ -72,6 +73,10 @@ static bool yoauth_parse_args_command_add(int argc, char **argv, } strncpy(args->key, optarg, sizeof(args->key) - 1); } break; + case 'h': { + yoauth_usage_command_add(); + exit(EXIT_SUCCESS); + } break; } } diff --git a/src/yoauth/exe/command_del.c b/src/yoauth/exe/command_del.c index bf8ca77..8b922af 100644 --- a/src/yoauth/exe/command_del.c +++ b/src/yoauth/exe/command_del.c @@ -13,8 +13,8 @@ void yoauth_usage_command_del() YOAUTH_OUTPUT(""); YOAUTH_TIP("e.g."); - YOAUTH_OUTPUT_KV("yoauth delete -a github", - "//!< delte account 'github'", 40); + YOAUTH_OUTPUT_KV("yoauth delete -a github", "//!< delte account 'github'", + 40); } typedef struct cmd_del_args { @@ -28,6 +28,7 @@ static bool yoauth_parse_args_command_del(int argc, char **argv, static struct option long_options[] = { { "user", required_argument, NULL, 'u' }, { "account", required_argument, NULL, 'a' }, + { "help", required_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; @@ -36,7 +37,7 @@ static bool yoauth_parse_args_command_del(int argc, char **argv, while (true) { int c = 0; int option_index = 0; - c = getopt_long(argc, argv, "u:a:", long_options, &option_index); + c = getopt_long(argc, argv, "u:a:h", long_options, &option_index); if (c == -1) { break; } @@ -60,6 +61,10 @@ static bool yoauth_parse_args_command_del(int argc, char **argv, } strncpy(args->account, optarg, sizeof(args->account) - 1); } break; + case 'h': { + yoauth_usage_command_del(); + exit(EXIT_SUCCESS); + } break; } } diff --git a/src/yoauth/exe/command_dump.c b/src/yoauth/exe/command_dump.c index 702295e..31edcb3 100644 --- a/src/yoauth/exe/command_dump.c +++ b/src/yoauth/exe/command_dump.c @@ -28,6 +28,7 @@ static bool yoauth_parse_args_command_dump(int argc, char **argv, static struct option long_options[] = { { "user", required_argument, NULL, 'u' }, { "output", required_argument, NULL, 'o' }, + { "help", required_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; @@ -36,7 +37,7 @@ static bool yoauth_parse_args_command_dump(int argc, char **argv, while (true) { int c = 0; int option_index = 0; - c = getopt_long(argc, argv, "u:o:", long_options, &option_index); + c = getopt_long(argc, argv, "u:o:h", long_options, &option_index); if (c == -1) { break; } @@ -60,6 +61,10 @@ static bool yoauth_parse_args_command_dump(int argc, char **argv, } strncpy(args->output, optarg, sizeof(args->output) - 1); } break; + case 'h': { + yoauth_usage_command_dump(); + exit(EXIT_SUCCESS); + } break; } } diff --git a/src/yoauth/exe/command_list.c b/src/yoauth/exe/command_list.c index 359ca46..d0c0f1f 100644 --- a/src/yoauth/exe/command_list.c +++ b/src/yoauth/exe/command_list.c @@ -30,6 +30,7 @@ static bool yoauth_parse_args_command_list(int argc, char **argv, static struct option long_options[] = { { "user", required_argument, NULL, 'u' }, { "filter", required_argument, NULL, 'f' }, + { "help", required_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; @@ -38,7 +39,7 @@ static bool yoauth_parse_args_command_list(int argc, char **argv, while (true) { int c = 0; int option_index = 0; - c = getopt_long(argc, argv, "u:f:", long_options, &option_index); + c = getopt_long(argc, argv, "u:f:h", long_options, &option_index); if (c == -1) { break; } @@ -62,6 +63,10 @@ static bool yoauth_parse_args_command_list(int argc, char **argv, } strncpy(args->filter, optarg, sizeof(args->filter) - 1); } break; + case 'h': { + yoauth_usage_command_list(); + exit(EXIT_SUCCESS); + } break; } } diff --git a/src/yoauth/exe/command_load.c b/src/yoauth/exe/command_load.c index ecbe93f..d77dfef 100644 --- a/src/yoauth/exe/command_load.c +++ b/src/yoauth/exe/command_load.c @@ -28,6 +28,7 @@ static bool yoauth_parse_args_command_load(int argc, char **argv, static struct option long_options[] = { { "user", required_argument, NULL, 'u' }, { "input", required_argument, NULL, 'i' }, + { "help", required_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; @@ -36,7 +37,7 @@ static bool yoauth_parse_args_command_load(int argc, char **argv, while (true) { int c = 0; int option_index = 0; - c = getopt_long(argc, argv, "u:i:", long_options, &option_index); + c = getopt_long(argc, argv, "u:i:h", long_options, &option_index); if (c == -1) { break; } @@ -60,6 +61,10 @@ static bool yoauth_parse_args_command_load(int argc, char **argv, } strncpy(args->input, optarg, sizeof(args->input) - 1); } break; + case 'h': { + yoauth_usage_command_load(); + exit(EXIT_SUCCESS); + } break; } } From df2bc1498c5b1dd8866ca268351fca5696eec59f Mon Sep 17 00:00:00 2001 From: Muggle Wei Date: Sun, 3 Sep 2023 23:40:57 +0800 Subject: [PATCH 3/3] update version to 1.0.9 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index b0f3d96..66c4c22 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.8 +1.0.9