aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-04-22 18:07:50 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-04-22 18:07:50 +0300
commit225600aadffc6fdb188fef230cdab67e1242e3a3 (patch)
tree026d4017b40906a0aa3b2044cf6b52049a053a1c /src/actions.c
parenteeca7f0151d85d563d1db229e3b7ca936323ffa2 (diff)
downloadck-225600aadffc6fdb188fef230cdab67e1242e3a3.tar.gz
ck-225600aadffc6fdb188fef230cdab67e1242e3a3.tar.bz2
ck-225600aadffc6fdb188fef230cdab67e1242e3a3.zip
Add almost done, opt parsing remains
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/actions.c b/src/actions.c
index 87c0a6c..4e9e4ca 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -42,9 +42,12 @@ int run_ADD(UserOpt * opt, Conf *conf) {
for (int i = 0; i < opt->argc; i++) {
printf("[%d]: %s\n", i, opt->argv[i]);
}
- add_insert_program_to_db(&db, opt->argv[1]);
+ // figure out user opt
+ if (add_transaction_begin(&db, opt->argv[0], opt->argv[1], 0, 0) == 0) {
+ return 0;
+ }
close_DB(&db);
- return 0;
+ return 1;
}
int run_DEL(UserOpt * opt, Conf *conf) {
@@ -59,6 +62,16 @@ int run_EDIT(UserOpt * opt, Conf *conf) {
int run_LIST(UserOpt * opt, Conf *conf) {
printf("Running %s\n", "list");
+ DB db = open_DB(opt);
+ if (db.ptr == NULL) {
+ if (db.error == SQL_ERR_NO_TABLES) {
+ printf("no tables\n");
+ }
+ }
+ for (int i = 0; i < opt->argc; i++) {
+ printf("[%d]: %s\n", i, opt->argv[i]);
+ }
+ close_DB(&db);
return 0;
}