aboutsummaryrefslogtreecommitdiffstats
path: root/src/actionparser.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-05-02 14:08:14 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-05-02 14:08:14 +0300
commitac8a32e855b078e137fe5de4c2bbf9628c004532 (patch)
tree0a72c0b7582f2de4c5e2c95779f7337c4f5b5f3b /src/actionparser.c
parenta28ef5a070463f31029ae1515e9e0bd703522447 (diff)
downloadck-ac8a32e855b078e137fe5de4c2bbf9628c004532.tar.gz
ck-ac8a32e855b078e137fe5de4c2bbf9628c004532.tar.bz2
ck-ac8a32e855b078e137fe5de4c2bbf9628c004532.zip
Basic config editting
Diffstat (limited to 'src/actionparser.c')
-rw-r--r--src/actionparser.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/actionparser.c b/src/actionparser.c
index 0dca98c..756d6d5 100644
--- a/src/actionparser.c
+++ b/src/actionparser.c
@@ -102,7 +102,16 @@ int parse_DEL(UserOpt *opt) {
return -1;
}
int parse_EDIT(UserOpt *opt) {
- return -1;
+ /* EDIT expects 1 to 2 arguments */
+ if (optNum <= pos || optNum > pos + 2) {
+ opt->err = PERR_EDIT_WRONG;
+ return -1;
+ }
+ opt->argc = optNum - pos;
+ for (int i = 0; i < opt->argc; i++) {
+ get_opt(i, opt);
+ }
+ return 1;
}
int parse_LIST(UserOpt *opt) {
return -1;
@@ -237,7 +246,7 @@ void get_possible_action_strings(char *dest, CkAction ckAction) {
}
void print_parser_error(UserOpt *opt) {
- char errStr[STR_M];
+ char errStr[STR_L];
char names[STR_S];
get_possible_action_strings(names, opt->action);
@@ -251,13 +260,13 @@ void print_parser_error(UserOpt *opt) {
sprintf(errStr, "Initialize database\nUsage: %s version_control_dir secret_dir", names);
break;
case PERR_ADD_WRONG:
- sprintf(errStr, "Add config (new or existing)\nUsage: %s ProgramName ConfigPath [-s](secret) [-p](primary)", names);
+ sprintf(errStr, "Add config \nUsage: %s ProgramName ConfigPath [-s](secret) [-p](primary)", names);
break;
case PERR_DEL_WRONG:
sprintf(errStr, "Delete config or program\nUsage: %s ProgramName ConfigPath [-s](secret) [-p](primary)", names);
break;
case PERR_EDIT_WRONG:
- sprintf(errStr, "Edit config\nUsage: add ProgramName ConfigPath [-s](secret) [-p](primary)");
+ sprintf(errStr, "Edit config with $EDITOR\nUsage: %s ProgramName or configBasename (or both)", names);
break;
case PERR_LIST_WRONG:
sprintf(errStr, "Usage: .........)");