summaryrefslogtreecommitdiffstats
path: root/subcmds/help.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-25 15:12:37 -0500
committerDavid Pursehouse <dpursehouse@collab.net>2020-03-17 00:08:52 +0000
commitd3639c53d56feaea81474ffd28395a124744dab7 (patch)
treee48227c75bb55a08c342f0a2d8e6ced9cadad5a7 /subcmds/help.py
parentf725e548db17281037d794f18aab3320d2580865 (diff)
downloadgit-repo-d3639c53d56feaea81474ffd28395a124744dab7.tar.gz
subcmds: centralize all_commands logic
The branch->branches alias is setup in the main module when that really belongs in the existing all_commands setup. For help, rather than monkey patching all_commands to the class, switch it to use the state directly from the module. This makes it a bit more obvious where it's coming from rather than this one subcommand having a |commands| member added externally to it. Change-Id: I0200def09bf4774cad8012af0f4ae60ea3089dc0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259153 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Diffstat (limited to 'subcmds/help.py')
-rw-r--r--subcmds/help.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/subcmds/help.py b/subcmds/help.py
index 36b3a7ae..5e24ed0b 100644
--- a/subcmds/help.py
+++ b/subcmds/help.py
@@ -19,6 +19,7 @@ import re
19import sys 19import sys
20from formatter import AbstractFormatter, DumbWriter 20from formatter import AbstractFormatter, DumbWriter
21 21
22from subcmds import all_commands
22from color import Coloring 23from color import Coloring
23from command import PagedCommand, MirrorSafeCommand, GitcAvailableCommand, GitcClientCommand 24from command import PagedCommand, MirrorSafeCommand, GitcAvailableCommand, GitcClientCommand
24import gitc_utils 25import gitc_utils
@@ -42,7 +43,7 @@ Displays detailed usage information about a command.
42 fmt = ' %%-%ds %%s' % maxlen 43 fmt = ' %%-%ds %%s' % maxlen
43 44
44 for name in commandNames: 45 for name in commandNames:
45 command = self.commands[name] 46 command = all_commands[name]
46 try: 47 try:
47 summary = command.helpSummary.strip() 48 summary = command.helpSummary.strip()
48 except AttributeError: 49 except AttributeError:
@@ -52,7 +53,7 @@ Displays detailed usage information about a command.
52 def _PrintAllCommands(self): 53 def _PrintAllCommands(self):
53 print('usage: repo COMMAND [ARGS]') 54 print('usage: repo COMMAND [ARGS]')
54 print('The complete list of recognized repo commands are:') 55 print('The complete list of recognized repo commands are:')
55 commandNames = list(sorted(self.commands)) 56 commandNames = list(sorted(all_commands))
56 self._PrintCommands(commandNames) 57 self._PrintCommands(commandNames)
57 print("See 'repo help <command>' for more information on a " 58 print("See 'repo help <command>' for more information on a "
58 'specific command.') 59 'specific command.')
@@ -73,7 +74,7 @@ Displays detailed usage information about a command.
73 return False 74 return False
74 75
75 commandNames = list(sorted([name 76 commandNames = list(sorted([name
76 for name, command in self.commands.items() 77 for name, command in all_commands.items()
77 if command.common and gitc_supported(command)])) 78 if command.common and gitc_supported(command)]))
78 self._PrintCommands(commandNames) 79 self._PrintCommands(commandNames)
79 80
@@ -132,8 +133,8 @@ Displays detailed usage information about a command.
132 out._PrintSection('Description', 'helpDescription') 133 out._PrintSection('Description', 'helpDescription')
133 134
134 def _PrintAllCommandHelp(self): 135 def _PrintAllCommandHelp(self):
135 for name in sorted(self.commands): 136 for name in sorted(all_commands):
136 cmd = self.commands[name] 137 cmd = all_commands[name]
137 cmd.manifest = self.manifest 138 cmd.manifest = self.manifest
138 self._PrintCommandHelp(cmd, header_prefix='[%s] ' % (name,)) 139 self._PrintCommandHelp(cmd, header_prefix='[%s] ' % (name,))
139 140
@@ -158,7 +159,7 @@ Displays detailed usage information about a command.
158 name = args[0] 159 name = args[0]
159 160
160 try: 161 try:
161 cmd = self.commands[name] 162 cmd = all_commands[name]
162 except KeyError: 163 except KeyError:
163 print("repo: '%s' is not a repo command." % name, file=sys.stderr) 164 print("repo: '%s' is not a repo command." % name, file=sys.stderr)
164 sys.exit(1) 165 sys.exit(1)