diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-10-26 13:52:32 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-10-26 13:52:32 +0300 |
commit | a6b2b4b2a4095d2f95419df986378e54432c2d71 (patch) | |
tree | ea94ac255bab5bf3665092c42207e8f3229411a2 /src/actions.c | |
parent | c3267a360860de225fa0af666d99f60d03266249 (diff) | |
download | ck-a6b2b4b2a4095d2f95419df986378e54432c2d71.tar.gz ck-a6b2b4b2a4095d2f95419df986378e54432c2d71.tar.bz2 ck-a6b2b4b2a4095d2f95419df986378e54432c2d71.zip |
Small corrections
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 25 |
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) { |