diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clparser.h | 2 | ||||
-rw-r--r-- | src/confparser.c | 2 | ||||
-rw-r--r-- | src/restore.c | 37 |
3 files changed, 13 insertions, 28 deletions
diff --git a/src/clparser.h b/src/clparser.h index 6e4cbea..1ba6d00 100644 --- a/src/clparser.h +++ b/src/clparser.h @@ -28,7 +28,7 @@ X(EDIT, 1, 5) \ X(LIST, 1, 6) \ X(SEARCH, 1, 1) \ - X(RESTORE, 1, 2) \ + X(RESTORE, 1, 1) \ X(EXPORT, 0, 0) \ X(HELP, 1, 1) diff --git a/src/confparser.c b/src/confparser.c index 48f0c71..f7b6268 100644 --- a/src/confparser.c +++ b/src/confparser.c @@ -88,7 +88,7 @@ int find_config(UserOpt *opt) { return 0; } } - LOG("$XDG_CONFIG_HOME not avaliable."); + ERR("No config found."); return -1; } diff --git a/src/restore.c b/src/restore.c index a18f906..426e803 100644 --- a/src/restore.c +++ b/src/restore.c @@ -129,44 +129,29 @@ int run_RESTORE(UserOpt *opt, Conf *conf) { cklist *from = list_make_new(); cklist *to = list_make_new(); int err_flag = 0; - if (strcmp(list_get(opt->args), "-p") == 0) { - if (list_next(opt->args)) { - if (program_exists(&db, list_get(opt->args))) { - if (restore_configs_exists(&db, conf, list_get(opt->args), from, to)) { - hLOG("Restoring links for %s...", list_get(opt->args)); - } - else { - err_flag = 1; - } + char *arg = list_get(opt->args); + if (strcmp(arg, "--all") != 0) { + if (program_exists(&db, arg)) { + if (restore_configs_exists(&db, conf, arg, from, to)) { + hLOG("Restoring links for %s...", arg); } else { - ERR("Program %s does not exist", list_get(opt->args)); err_flag = 1; } } else { - sERR("-p needs a program name"); + ERR("Program %s does not exist", arg); err_flag = 1; } } - else if (strcmp(list_get(opt->args), "all") == 0) { - if (!list_next(opt->args)) { - if (restore_all_exist(&db, conf, from, to)) { - hLOG("Restoring all links..."); - } - else { - err_flag = 1; - } + else { + if (restore_all_exist(&db, conf, from, to)) { + hLOG("Restoring all links..."); } else { - sERR("Wrong argument"); err_flag = 1; } } - else { - sERR("Wrong argument"); - err_flag = 1; - } close_DB(&db); int rc = -1; if (!err_flag) { @@ -181,7 +166,7 @@ int run_RESTORE(UserOpt *opt, Conf *conf) { } void print_RESTORE_help() { - ckhelp("ck restore -p PROGRAM_NAME"); - ckhelp("ck restore all"); + ckhelp("ck restore PROGRAM_NAME"); + ckhelp("ck restore --all"); report_help(); } |