diff options
author | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-09-22 23:25:35 +0300 |
---|---|---|
committer | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-09-22 23:25:35 +0300 |
commit | ff04205b2d794ae9157f9c423295da97bcebd90e (patch) | |
tree | 06d3a5abecb2c3954d6c4895ee0362d38836ecb1 /src/actionparser.c | |
parent | 405afc36e0929d887188be09a5886f79ff0ea1c4 (diff) | |
download | ck-ff04205b2d794ae9157f9c423295da97bcebd90e.tar.gz ck-ff04205b2d794ae9157f9c423295da97bcebd90e.tar.bz2 ck-ff04205b2d794ae9157f9c423295da97bcebd90e.zip |
Add search action
Diffstat (limited to 'src/actionparser.c')
-rw-r--r-- | src/actionparser.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/actionparser.c b/src/actionparser.c index a1fd1ef..580eb01 100644 --- a/src/actionparser.c +++ b/src/actionparser.c @@ -123,7 +123,15 @@ int parse_LIST(UserOpt *opt) { return 1; } int parse_SEARCH(UserOpt *opt) { - return -1; + /* Search expects a maximum of 1 argument */ + if (optNum > pos + 1) { + opt->err = PERR_SEARCH_WRONG; + return -1; + } + + int arg_num = optNum - pos; + fill_args_list(arg_num, opt); + return 1; } int parse_HELP(UserOpt *opt) { return -1; @@ -272,7 +280,7 @@ void print_parser_error(UserOpt *opt) { sprintf(errStr, "List programs, configs and more\nUsage: %s value-to-list (or tree) [-t list-type]", names); break; case PERR_SEARCH_WRONG: - sprintf(errStr, "Usage: ............."); + sprintf(errStr, "Search through the configs with grep\nUsage: %s search-term", names); break; case PERR_HELP_WRONG: sprintf(errStr, "Usage: ........"); |