aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/actions.c b/src/actions.c
index 4fc033e..b887399 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -24,7 +24,7 @@ int run_INIT(UserOpt * opt, Conf *conf) {
return -1;
}
if (init_create_config_file(opt)) {
- HELP("Cound not create config file.");
+ sERR("Cound not create config file.");
return -2;
}
DB db = init_make_DB(opt);
@@ -73,29 +73,28 @@ int run_ADD(UserOpt * opt, Conf *conf) {
int run_DEL(UserOpt * opt, Conf *conf) {
UNUSED(conf);
- DB db = open_DB(opt);
- if (db.ptr == NULL) {
- if (db.error == SQL_ERR_NO_TABLES) {
- ERR("The database file is currupted. Run ck init anew.");
- }
- goto error;
- }
+ DB db;
DelOpt delOpt = del_make_options(opt->args);
switch(delOpt.err) {
case DEL_NO_ERR:
- del_transaction_try(&db, delOpt.arg, delOpt.isConf);
+ db = open_DB(opt);
+ if (db.ptr == NULL) {
+ if (db.error == SQL_ERR_NO_TABLES) {
+ ERR("The database file is currupted. Run ck init anew.");
+ }
+ return -2;
+ }
+ int rc = del_transaction_try(&db, delOpt.arg, delOpt.isConf);
close_DB(&db);
- return 0;
+ return rc;
case DEL_ERR_WRONG_ARGS:
ERR("Wrong delete arguments.");
break;
case DEL_ERR_WRONG_PATH:
ERR("Path %s doesnt exist.", delOpt.arg);
}
- error:
- close_DB(&db);
- return 1;
+ return -2;
}
int run_EDIT(UserOpt *opt, Conf *conf) {