aboutsummaryrefslogtreecommitdiffstats
path: root/src/ck.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ck.c')
-rw-r--r--src/ck.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/ck.c b/src/ck.c
index 56dec2e..2833176 100644
--- a/src/ck.c
+++ b/src/ck.c
@@ -7,18 +7,7 @@
#include "confparser.h"
#include "dblayer.h"
- int main(int argc, char *argv[]) {
- sqlite3 *db;
- int rc;
-
- Conf conf;
- config_file_parse(&conf);
- //return 1;
-
-#define X(var, str, name) \
- printf("%s: %s\n", name, conf.var);
- CONFIG_VARIABLES_TABLE
-#undef X
+int main(int argc, char *argv[]) {
UserOpt opt;
switch(parseAction(argc, argv, &opt)) {
case OPR_HELP:
@@ -27,18 +16,37 @@
printParserError(&opt);
case OPR_OK:
break;
- //
}
+ printf("%s\n", opt.confDir);
+ Conf conf;
+ if (opt.action != CKA_INIT) {
+ if (!db_exists()) {
+ printf("ck is not initialized.\nRun ck init first.\n");
+ return 1;
+ }
+ if (!config_file_parse(&conf)) {
+ return 1;
+ }
+ }
+
+ int ok;
switch(opt.action) {
#define X(ACTION) \
case CKA_##ACTION: \
- run_##ACTION(&opt, &conf); \
+ ok = run_##ACTION(&opt, &conf); \
break;
CK_ACTIONS
#undef X
-
}
+ switch(opt.action) {
+#define X(ACTION) \
+ case CKA_##ACTION: \
+ print_##ACTION##_result(ok); \
+ break;
+ CK_ACTIONS
+#undef X
+ }
return 0;
}