URL: https://github.com/SSSD/sssd/pull/515 Title: #515: sssctl: Showing help even when sssd not configured
pbrezina commented: """ No, this is not correct usage of popt. You want something like this: ```c static void sss_tool_common_opts(struct sss_tool_ctx *tool_ctx, - int *argc, const char **argv) + int *argc, const char **argv, + bool *_help) { poptContext pc; int debug = SSSDBG_DEFAULT; int orig_argc = *argc; + int help = 0; int opt; struct poptOption options[] = { {"debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_STRIP, &debug, 0, _("The debug level to run with"), NULL }, + {"help", '?', POPT_ARG_VAL | POPT_ARGFLAG_DOC_HIDDEN, &help, + 1, NULL, NULL }, POPT_TABLEEND }; @@ -74,6 +78,7 @@ static void sss_tool_common_opts(struct sss_tool_ctx *tool_ctx, /* Strip common options from arguments. We will discard_const here, * since it is not worth the trouble to convert it back and forth. */ *argc = poptStrippedArgv(pc, orig_argc, discard_const_p(char *, argv)); + *_help = help; DEBUG_CLI_INIT(debug); ``` """ See the full comment at https://github.com/SSSD/sssd/pull/515#issuecomment-368818331
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org