diff options
author | Pavel Březina <pbrezina@redhat.com> | 2015-10-20 12:22:23 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-10-30 11:49:44 +0100 |
commit | 16065cc731687eb8779d31b79436bbf79c5e3ed3 (patch) | |
tree | f14b3c938f61e4548a450cf497872959bb6a4c1f | |
parent | bbe74392605808f6c7f1fda6e8c3c66fbfb035f4 (diff) | |
download | sssd-16065cc731687eb8779d31b79436bbf79c5e3ed3.tar.gz sssd-16065cc731687eb8779d31b79436bbf79c5e3ed3.tar.xz sssd-16065cc731687eb8779d31b79436bbf79c5e3ed3.zip |
sss_tools: always show common and help options
popt don't handle merging NULL option table, thus common and help
options were not displayed when command doesn't have any options.
Reviewed-by: Pavel Reichl <preichl@redhat.com>
-rw-r--r-- | src/tools/common/sss_tools.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index c0b525555..abb9dbace 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -262,6 +262,19 @@ int sss_tool_route(int argc, const char **argv, return sss_tool_usage(argv[0], commands); } +static struct poptOption *nonnull_popt_table(struct poptOption *options) +{ + static struct poptOption empty[] = { + POPT_TABLEEND + }; + + if (options == NULL) { + return empty; + } + + return options; +} + int sss_tool_popt_ex(struct sss_cmdline *cmdline, struct poptOption *options, enum sss_tool_opt require_option, @@ -272,7 +285,7 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline, const char **_fopt) { struct poptOption opts_table[] = { - {NULL, '\0', POPT_ARG_INCLUDE_TABLE, options, \ + {NULL, '\0', POPT_ARG_INCLUDE_TABLE, nonnull_popt_table(options), \ 0, _("Command options:"), NULL }, {NULL, '\0', POPT_ARG_INCLUDE_TABLE, sss_tool_common_opts_table(), \ 0, _("Common options:"), NULL }, |