diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-09-27 16:54:43 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-09-27 16:54:43 +0300 |
commit | 65986f9cd9429c7876e5d2f09e4a0cd19d966fa3 (patch) | |
tree | a77f12361571bd6c89ccd478db3dba2866719df3 /src/actions.c | |
parent | 03917439a1ddcf202e9fc53937b10eeb7ec0a99a (diff) | |
download | ck-65986f9cd9429c7876e5d2f09e4a0cd19d966fa3.tar.gz ck-65986f9cd9429c7876e5d2f09e4a0cd19d966fa3.tar.bz2 ck-65986f9cd9429c7876e5d2f09e4a0cd19d966fa3.zip |
Add dummy delete
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 28 |
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; } |