diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-10-18 11:19:36 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-10-18 11:19:36 +0300 |
commit | 505dd4d9170c1435777eb6fcd306d078056ea35e (patch) | |
tree | 9fd0fc9850df1439b2b7513a0c1501c985c590e6 | |
parent | 4c6d49f7d8ee1e6e6b849f16dc821e83d8967af8 (diff) | |
download | ck-505dd4d9170c1435777eb6fcd306d078056ea35e.tar.gz ck-505dd4d9170c1435777eb6fcd306d078056ea35e.tar.bz2 ck-505dd4d9170c1435777eb6fcd306d078056ea35e.zip |
Add man option to help
-rw-r--r-- | src/actionparser.h | 3 | ||||
-rw-r--r-- | src/actions.c | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/actionparser.h b/src/actionparser.h index 657acbc..def4c8f 100644 --- a/src/actionparser.h +++ b/src/actionparser.h @@ -68,9 +68,8 @@ struct UserOptions { /* Parse cli args, fill UserOpt struct * and return the result enum */ extern int parse_action(int argc, char* argv[], UserOpt *opt); -extern void print_parser_error(); -extern void print_parser_help(); extern CkAction parser_get_action(const char *name, char *actionName); +extern void get_possible_action_strings(char *dest, CkAction ckAction); extern void free_user_opt(UserOpt *opt); #endif // ACTIONPARSER_H diff --git a/src/actions.c b/src/actions.c index 501d952..417f9ce 100644 --- a/src/actions.c +++ b/src/actions.c @@ -269,9 +269,23 @@ int run_SEARCH(UserOpt *opt, Conf *conf) { int run_HELP(UserOpt *opt, Conf *conf) { UNUSED(conf); + char tmp[STR_M]; + if (strcmp(list_get(opt->args), "man") == 0) { +#define X(ACTION) \ + get_possible_action_strings(tmp, CKA_##ACTION); \ + HELP("%s:\n%s", #ACTION, tmp); \ + print_##ACTION##_help(); \ + HELP(""); + CK_ACTIONS +#undef X + return 0; + } + switch(parser_get_action(list_get(opt->args), NULL)) { #define X(ACTION) \ case CKA_##ACTION: \ + get_possible_action_strings(tmp, CKA_##ACTION); \ + HELP("%s:\n%s", #ACTION, tmp); \ print_##ACTION##_help(); \ return 0; CK_ACTIONS |