From ff04205b2d794ae9157f9c423295da97bcebd90e Mon Sep 17 00:00:00 2001 From: Anastasis Grammenos Date: Sat, 22 Sep 2018 23:25:35 +0300 Subject: Add search action --- src/actionparser.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/actionparser.c') 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: ........"); -- cgit v1.2.3