Re: [PATCH v3 6/9] help: simplify by moving to OPT_CMDMODE()
From: Junio C Hamano <hidden>
Date: 2021-09-23 18:03:58
Ævar Arnfjörð Bjarmason [off-list ref] writes:
+static void no_extra_argc(int argc)
+{
+ if (argc)
+ usage_msg_opt(_("this option doesn't take any other arguments"),
+ builtin_help_usage, builtin_help_options);
+}
The mention of "this option" smells like a loss of information. I
might expect the --verbose option might take the verbosity level and
ask for
$ git help --guides --verbose 99
and the above message may give me a false impression that "this
option" refers to "--verbose" that does not take any value.
As long as --all/--guides/--config are understood as "special" and
different from other options, this may be OK, especially given that
the user will get an error message much earlier if you give two or
more of them at the same time, so such an "which option do you
mean?" confusion may not happen very often.
quoted hunk
int cmd_help(int argc, const char **argv, const char *prefix) { int nongit;@@ -554,28 +570,8 @@ int cmd_help(int argc, const char **argv, const char *prefix) builtin_help_usage, 0); parsed_help_format = help_format; + switch (cmd_mode) { + case HELP_ACTION_ALL: git_config(git_help_config, NULL); if (verbose) { setup_pager();@@ -585,25 +581,20 @@ int cmd_help(int argc, const char **argv, const char *prefix) printf(_("usage: %s%s"), _(git_usage_string), "\n\n"); load_command_list("git-", &main_cmds, &other_cmds); list_commands(colopts, &main_cmds, &other_cmds); + printf("%s\n", _(git_more_info_string)); + break; + case HELP_ACTION_GUIDES: + no_extra_argc(argc); list_guides_help(); printf("%s\n", _(git_more_info_string)); return 0; + case HELP_ACTION_CONFIG_FOR_COMPLETION: + list_config_help(0); + return 0; + case HELP_ACTION_CONFIG: + no_extra_argc(argc); setup_pager(); + list_config_help(1); printf("\n%s\n", _("'git help config' for more information")); return 0; }