aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c28
1 files changed, 27 insertions, 1 deletions
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;
}