aboutsummaryrefslogtreecommitdiffstats
path: root/src/actionparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/actionparser.c')
-rw-r--r--src/actionparser.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/actionparser.c b/src/actionparser.c
index deae72a..d5ad071 100644
--- a/src/actionparser.c
+++ b/src/actionparser.c
@@ -18,7 +18,7 @@
#include "ckinfo.h"
#include "ckerrlog.h"
-#define COMPONENT "action parser"
+ERRLOG(action parser);
/* accepted commands */
/* [0] is the count */
@@ -30,7 +30,9 @@ const char* const strLIST[] = {"5", "list", "ls", "l", "-l", "-ls"};
const char* const strSEARCH[] = {"3", "search", "s", "-s"};
const char* const strHELP[] = {"5", "help", "h", "-?", "-h", "--help"};
const char* const strConfDir[] = {"4", "config", "conf", "c", "-c"};
-const char* const strVersion[] = {"4", "version", "--version", "-v", "-V"};
+const char* const strVersion[] = {"2", "version", "--version"};
+const char* const strVerbose1[] = {"2", "--verbose", "-v"};
+const char* const strVerbose2[] = {"2", "--Verbose", "-V"};
/* Number of opts */
static int optNum;
@@ -140,7 +142,7 @@ int parse_LIST(UserOpt *opt) {
int parse_SEARCH(UserOpt *opt) {
/* Search expects a maximum of 1 argument */
- if (optNum > pos + 1) {
+ if (optNum <= pos || optNum > pos + 1) {
opt->err = PERR_SEARCH_WRONG;
return -1;
}
@@ -264,6 +266,29 @@ int version() {
return 0;
}
+void verbose() {
+ /* get first token */
+ next_token();
+
+ for (int i = 1; i < atoi(strVerbose1[0]) + 1; i++) {
+ if (strcmp(token, strVerbose1[i]) == 0) {
+ errlog_set_verbose(1);;
+ return;
+ }
+ }
+
+ for (int i = 1; i < atoi(strVerbose2[0]) + 1; i++) {
+ if (strcmp(token, strVerbose2[i]) == 0) {
+ errlog_set_verbose(2);;
+ return;
+ }
+ }
+
+ // rewind
+ pos = pos - 1;
+ token = opts[pos];
+}
+
void get_possible_action_strings(char *dest, CkAction ckAction) {
char buf[STR_S];
switch (ckAction) {
@@ -361,6 +386,9 @@ ActionParseResult parse_action(int argc, char* argv[], UserOpt *opt) {
return APR_VERSION;
}
+ /* set verbose level */
+ verbose();
+
/* figure what is the config file */
get_config(opt);
cklog("Found ck configuration directory in %s", opt->confDir);