aboutsummaryrefslogtreecommitdiffstats
path: root/src/restore.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-11-20 20:21:29 +0200
committergramanas <anastasis.gramm2@gmail.com>2018-11-20 20:21:29 +0200
commitbd85acf6a408674bcdcb5116963fe4fea2247280 (patch)
tree4318ff7e1331b16cb9152f45601eedb89b30fb92 /src/restore.c
parentda31bfd28301d63571eccb4abdd6b0a65b05c621 (diff)
downloadck-bd85acf6a408674bcdcb5116963fe4fea2247280.tar.gz
ck-bd85acf6a408674bcdcb5116963fe4fea2247280.tar.bz2
ck-bd85acf6a408674bcdcb5116963fe4fea2247280.zip
Simplyfy restore arguments
Diffstat (limited to 'src/restore.c')
-rw-r--r--src/restore.c37
1 files changed, 11 insertions, 26 deletions
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();
}