From a6b2b4b2a4095d2f95419df986378e54432c2d71 Mon Sep 17 00:00:00 2001 From: gramanas Date: Fri, 26 Oct 2018 13:52:32 +0300 Subject: Small corrections --- src/actions.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/actions.c') 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) { -- cgit v1.2.3