From 225600aadffc6fdb188fef230cdab67e1242e3a3 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 22 Apr 2018 18:07:50 +0300 Subject: Add almost done, opt parsing remains --- src/actions.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/actions.c') 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; } -- cgit v1.2.3