aboutsummaryrefslogtreecommitdiffstats
path: root/src/help.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-11-17 19:49:52 +0200
committergramanas <anastasis.gramm2@gmail.com>2018-11-17 19:49:52 +0200
commit21c92f735ff52ff98b50f7f9d8e8ab9c46dad557 (patch)
tree3b244ec29c3b3ad96fc141461bff4d141a36227a /src/help.c
parent8eb4df24eb30353bea82268440396e50ed8b1bbc (diff)
downloadck-21c92f735ff52ff98b50f7f9d8e8ab9c46dad557.tar.gz
ck-21c92f735ff52ff98b50f7f9d8e8ab9c46dad557.tar.bz2
ck-21c92f735ff52ff98b50f7f9d8e8ab9c46dad557.zip
Finish restructure and simplify include graph
Diffstat (limited to 'src/help.c')
-rw-r--r--src/help.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/help.c b/src/help.c
new file mode 100644
index 0000000..ead8d45
--- /dev/null
+++ b/src/help.c
@@ -0,0 +1,53 @@
+/* help.c - the help action --------------------------------------------*- C -*-
+ *
+ * This file is part of ck, the config keeper
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2018 Anastasis Grammenos
+ * GPLv3 (see LICENCE for the full notice)
+ *
+ * -------------------------------------------------------------------------- */
+#include "dblayer.h"
+#include "ckerrlog.h"
+
+ERRLOG(action);
+
+static void print_conf_help(void) {
+ HELP("ck [-v|--verbose] [-c|--config DIR] action [...]");
+}
+
+static void print_verbose_help(void) {
+ HELP("ck [-v|--verbose] [-c|--config DIR] action [...]");
+}
+
+int run_HELP(UserOpt *opt, Conf *conf) {
+ UNUSED(conf);
+ char tmp[STR_M] = "";
+ if (strcmp(list_get(opt->args), "config") == 0) {
+ print_conf_help();
+ return 0;
+ }
+
+ if (strcmp(list_get(opt->args), "verbose") == 0) {
+ print_verbose_help();
+ return 0;
+ }
+
+ switch(parser_get_action(list_get(opt->args), NULL)) {
+#define X(ACTION, MIN, MAX) \
+ case CKA_##ACTION: \
+ HELP("%s", get_possible_action_strings(tmp, CKA_##ACTION)); \
+ print_##ACTION##_help(); \
+ return 0;
+ CK_ACTIONS
+#undef X
+ default:
+ ERR("Unknown action: %s", list_get(opt->args));
+ }
+ return -1;
+}
+
+void print_HELP_help() {
+ HELP("ck help action");
+}