From 65986f9cd9429c7876e5d2f09e4a0cd19d966fa3 Mon Sep 17 00:00:00 2001 From: gramanas Date: Thu, 27 Sep 2018 16:54:43 +0300 Subject: Add dummy delete --- src/actions.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/actions.c') diff --git a/src/actions.c b/src/actions.c index 54e781b..70705e4 100644 --- a/src/actions.c +++ b/src/actions.c @@ -72,7 +72,33 @@ int run_ADD(UserOpt * opt, Conf *conf) { } int run_DEL(UserOpt * opt, Conf *conf) { - printf("Running %s\n", "del"); + printf("Running del\n"); + DB db = open_DB(opt); + if (db.ptr == NULL) { + if (db.error == SQL_ERR_NO_TABLES) { + PRINT_ERR("The database file is currupted. Run ck init anew."); + } + goto error; + } + + DelOpt delOpt = del_make_options(opt->args); + switch(delOpt.err) { + case DEL_NO_ERR: + if (delOpt.isConf) { + printf("deleting conf %s\n", delOpt.path); + } else { + printf("Deleting program %s\n", delOpt.prog); + } + close_DB(&db); + return 0; + case DEL_ERR_WRONG_ARGS: + printf("wrong del args\n"); + break; + case DEL_ERR_WRONG_PATH: + printf("path %s doesnt exist\n", delOpt.path); + } + error: + close_DB(&db); return 1; } -- cgit v1.2.3