mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
help: unify command display
No functional changes, just unifying duplicate code paths. Change-Id: I6afa797ca1e1eb90abdc0236325003ae070cbfb3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/247293 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
4997d1c838
commit
0b304c06ff
@ -33,11 +33,8 @@ class Help(PagedCommand, MirrorSafeCommand):
|
|||||||
Displays detailed usage information about a command.
|
Displays detailed usage information about a command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _PrintAllCommands(self):
|
def _PrintCommands(self, commandNames):
|
||||||
print('usage: repo COMMAND [ARGS]')
|
"""Helper to display |commandNames| summaries."""
|
||||||
print('The complete list of recognized repo commands are:')
|
|
||||||
commandNames = list(sorted(self.commands))
|
|
||||||
|
|
||||||
maxlen = 0
|
maxlen = 0
|
||||||
for name in commandNames:
|
for name in commandNames:
|
||||||
maxlen = max(maxlen, len(name))
|
maxlen = max(maxlen, len(name))
|
||||||
@ -50,6 +47,12 @@ Displays detailed usage information about a command.
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
summary = ''
|
summary = ''
|
||||||
print(fmt % (name, summary))
|
print(fmt % (name, summary))
|
||||||
|
|
||||||
|
def _PrintAllCommands(self):
|
||||||
|
print('usage: repo COMMAND [ARGS]')
|
||||||
|
print('The complete list of recognized repo commands are:')
|
||||||
|
commandNames = list(sorted(self.commands))
|
||||||
|
self._PrintCommands(commandNames)
|
||||||
print("See 'repo help <command>' for more information on a "
|
print("See 'repo help <command>' for more information on a "
|
||||||
'specific command.')
|
'specific command.')
|
||||||
|
|
||||||
@ -71,19 +74,8 @@ Displays detailed usage information about a command.
|
|||||||
commandNames = list(sorted([name
|
commandNames = list(sorted([name
|
||||||
for name, command in self.commands.items()
|
for name, command in self.commands.items()
|
||||||
if command.common and gitc_supported(command)]))
|
if command.common and gitc_supported(command)]))
|
||||||
|
self._PrintCommands(commandNames)
|
||||||
|
|
||||||
maxlen = 0
|
|
||||||
for name in commandNames:
|
|
||||||
maxlen = max(maxlen, len(name))
|
|
||||||
fmt = ' %%-%ds %%s' % maxlen
|
|
||||||
|
|
||||||
for name in commandNames:
|
|
||||||
command = self.commands[name]
|
|
||||||
try:
|
|
||||||
summary = command.helpSummary.strip()
|
|
||||||
except AttributeError:
|
|
||||||
summary = ''
|
|
||||||
print(fmt % (name, summary))
|
|
||||||
print(
|
print(
|
||||||
"See 'repo help <command>' for more information on a specific command.\n"
|
"See 'repo help <command>' for more information on a specific command.\n"
|
||||||
"See 'repo help --all' for a complete list of recognized commands.")
|
"See 'repo help --all' for a complete list of recognized commands.")
|
||||||
|
Loading…
Reference in New Issue
Block a user