From 21c92f735ff52ff98b50f7f9d8e8ab9c46dad557 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sat, 17 Nov 2018 19:49:52 +0200 Subject: Finish restructure and simplify include graph --- src/help.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/help.c (limited to 'src/help.c') 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"); +} -- cgit v1.2.3