summaryrefslogtreecommitdiffstats
path: root/subcmds/help.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/help.py')
-rw-r--r--subcmds/help.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/subcmds/help.py b/subcmds/help.py
index 16f1f7f9..78930502 100644
--- a/subcmds/help.py
+++ b/subcmds/help.py
@@ -33,11 +33,8 @@ class Help(PagedCommand, MirrorSafeCommand):
33Displays detailed usage information about a command. 33Displays detailed usage information about a command.
34""" 34"""
35 35
36 def _PrintAllCommands(self): 36 def _PrintCommands(self, commandNames):
37 print('usage: repo COMMAND [ARGS]') 37 """Helper to display |commandNames| summaries."""
38 print('The complete list of recognized repo commands are:')
39 commandNames = list(sorted(self.commands))
40
41 maxlen = 0 38 maxlen = 0
42 for name in commandNames: 39 for name in commandNames:
43 maxlen = max(maxlen, len(name)) 40 maxlen = max(maxlen, len(name))
@@ -50,6 +47,12 @@ Displays detailed usage information about a command.
50 except AttributeError: 47 except AttributeError:
51 summary = '' 48 summary = ''
52 print(fmt % (name, summary)) 49 print(fmt % (name, summary))
50
51 def _PrintAllCommands(self):
52 print('usage: repo COMMAND [ARGS]')
53 print('The complete list of recognized repo commands are:')
54 commandNames = list(sorted(self.commands))
55 self._PrintCommands(commandNames)
53 print("See 'repo help <command>' for more information on a " 56 print("See 'repo help <command>' for more information on a "
54 'specific command.') 57 'specific command.')
55 58
@@ -71,19 +74,8 @@ Displays detailed usage information about a command.
71 commandNames = list(sorted([name 74 commandNames = list(sorted([name
72 for name, command in self.commands.items() 75 for name, command in self.commands.items()
73 if command.common and gitc_supported(command)])) 76 if command.common and gitc_supported(command)]))
77 self._PrintCommands(commandNames)
74 78
75 maxlen = 0
76 for name in commandNames:
77 maxlen = max(maxlen, len(name))
78 fmt = ' %%-%ds %%s' % maxlen
79
80 for name in commandNames:
81 command = self.commands[name]
82 try:
83 summary = command.helpSummary.strip()
84 except AttributeError:
85 summary = ''
86 print(fmt % (name, summary))
87 print( 79 print(
88"See 'repo help <command>' for more information on a specific command.\n" 80"See 'repo help <command>' for more information on a specific command.\n"
89"See 'repo help --all' for a complete list of recognized commands.") 81"See 'repo help --all' for a complete list of recognized commands.")