aboutsummaryrefslogtreecommitdiffstats
path: root/src/ck.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-04-15 06:15:06 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-04-15 06:15:06 +0300
commit6f319efab77e88e06acb689923ad619bf4c78304 (patch)
tree8d13fc584108627efb5d6b769e64a690b7d9552a /src/ck.c
parentc42092733d664c29d3ac9084859f57ec463f72e3 (diff)
downloadck-6f319efab77e88e06acb689923ad619bf4c78304.tar.gz
ck-6f319efab77e88e06acb689923ad619bf4c78304.tar.bz2
ck-6f319efab77e88e06acb689923ad619bf4c78304.zip
variable conf
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;
}