aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-09-27 16:54:43 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-09-27 16:54:43 +0300
commit65986f9cd9429c7876e5d2f09e4a0cd19d966fa3 (patch)
treea77f12361571bd6c89ccd478db3dba2866719df3 /src/actions.c
parent03917439a1ddcf202e9fc53937b10eeb7ec0a99a (diff)
downloadck-65986f9cd9429c7876e5d2f09e4a0cd19d966fa3.tar.gz
ck-65986f9cd9429c7876e5d2f09e4a0cd19d966fa3.tar.bz2
ck-65986f9cd9429c7876e5d2f09e4a0cd19d966fa3.zip
Add dummy delete
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;
}