From 56345c345bdfdd71399d17ccd0ffe8f39bf720eb Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 26 Jul 2021 23:46:32 -0400 Subject: repo: refactor help output handling Currently we have the behavior: * `repo`: Equivalent to `repo help` -- only shows common subcommands (with short description), and then exits 0. * `repo --help`: Shows repo's core options, lists all commands (no specific info), and then exits 0. The first case is not behaving well: * If you run `repo` without a specific subcommand, that's an error, so we should be exiting 1 instead. * Showing only subcommands and no actual option summary makes it seem like repo itself doesn't take any options. This confuses users. Let's rework things a bit. Now we have the behavior: * `repo`: Shows repo's core options, lists all commands (no specific info), and then exits 1. * `repo --help`: Shows repo's core options, shows common subcommands (with short description), and then exits 0. * `repo --help-all`: Shows repo's core options, shows all subcommands (with short description), and then exits 0. Basically we swap the behavior of `repo` and `repo --help`, and fix the exit status when the subcommand is missing. The addition of --help-all is mostly for the man pages. We were relying on `repo help --all` to generate the repo(1) man page, but that too omitted the core repo options. Now the man page includes all the core repo options and provides a summary of all commands. Change-Id: I1f99b99d5b8af2591f96a078d0647a3d76d6b0fc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312908 Reviewed-by: Xin Li Tested-by: Mike Frysinger --- subcmds/help.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'subcmds/help.py') diff --git a/subcmds/help.py b/subcmds/help.py index f302e75c..1a60ef45 100644 --- a/subcmds/help.py +++ b/subcmds/help.py @@ -50,14 +50,21 @@ Displays detailed usage information about a command. def _PrintAllCommands(self): print('usage: repo COMMAND [ARGS]') + self.PrintAllCommandsBody() + + def PrintAllCommandsBody(self): print('The complete list of recognized repo commands are:') commandNames = list(sorted(all_commands)) self._PrintCommands(commandNames) print("See 'repo help ' for more information on a " 'specific command.') + print('Bug reports:', Wrapper().BUG_URL) def _PrintCommonCommands(self): print('usage: repo COMMAND [ARGS]') + self.PrintCommonCommandsBody() + + def PrintCommonCommandsBody(self): print('The most commonly used repo commands are:') def gitc_supported(cmd): -- cgit v1.2.3-54-g00ecf