From 401820e28b74e09bffdeaa25fcf6de518487a433 Mon Sep 17 00:00:00 2001 From: Anastasis Grammenos Date: Sat, 27 Oct 2018 00:49:06 +0300 Subject: restore --- src/actionparser.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/actionparser.c') diff --git a/src/actionparser.c b/src/actionparser.c index 529876e..c4bfbc5 100644 --- a/src/actionparser.c +++ b/src/actionparser.c @@ -24,6 +24,7 @@ const char* const strEDIT[] = {"3", "edit", "e", "-e"}; const char* const strLIST[] = {"5", "list", "ls", "l", "-l", "-ls"}; const char* const strSEARCH[] = {"4", "search", "grep", "s", "-s"}; const char* const strHELP[] = {"5", "help", "h", "-?", "-h", "--help"}; +const char* const strRESTORE[] = {"3", "restore","r", "-r"}; const char* const strConfDir[] = {"2", "config", "-c"}; const char* const strVersion[] = {"2", "version", "--version"}; const char* const strVerbose1[] = {"2", "--verbose", "-v"}; @@ -160,6 +161,18 @@ int parse_HELP(UserOpt *opt) { return 0; } +int parse_RESTORE(UserOpt *opt) { + /* Restore expects 1 to 2 arguments */ + if (optNum < pos + 1 + || optNum > pos + 2) { + opt->err = PERR_RESTORE_WRONG; + return -1; + } + + int arg_num = optNum - pos; + fill_args_list(arg_num, opt); + return 0; +} int parse_vals(UserOpt *opt) { switch (opt->action) { @@ -354,6 +367,9 @@ void print_parser_error(UserOpt *opt) { break; case PERR_HELP_WRONG: sprintf(errStr, "Get help for a ck action.\nUsage: %s action", names); + break; + case PERR_RESTORE_WRONG: + sprintf(errStr, "Restore links of programs.\nUsage: %s {all} | {-p programName}", names); } HELP("%s", errStr); } @@ -373,9 +389,11 @@ void print_parser_help() { get_possible_action_strings(names, CKA_LIST); ckhelp("List configs: \t%s", names); get_possible_action_strings(names, CKA_SEARCH); - ckhelp("Search: \t%s", names); + ckhelp("Search configs: \t%s", names); + get_possible_action_strings(names, CKA_RESTORE); + ckhelp("Restore links: \t%s", names); get_possible_action_strings(names, CKA_HELP); - ckhelp("Actions Help: \t%s", names); + ckhelp("Help: \t%s", names); report_help(); } -- cgit v1.2.3