[commands] Add Command.usage argument to override argument display.

This commit is contained in:
Michael Van Buren 2017-02-08 20:54:28 -08:00 committed by Rapptz
parent bfe2b4fc03
commit 84dfd7b3e3
2 changed files with 6 additions and 1 deletions

View File

@ -93,6 +93,8 @@ class Command:
brief : str brief : str
The short help text for the command. If this is not specified The short help text for the command. If this is not specified
then the first line of the long help text is used instead. then the first line of the long help text is used instead.
usage : str
A replacement for arguments in the default help text.
aliases : list aliases : list
The list of aliases the command can be invoked under. The list of aliases the command can be invoked under.
pass_context : bool pass_context : bool
@ -145,6 +147,7 @@ class Command:
self.enabled = kwargs.get('enabled', True) self.enabled = kwargs.get('enabled', True)
self.help = kwargs.get('help') self.help = kwargs.get('help')
self.brief = kwargs.get('brief') self.brief = kwargs.get('brief')
self.usage = kwargs.get('usage')
self.rest_is_raw = kwargs.get('rest_is_raw', False) self.rest_is_raw = kwargs.get('rest_is_raw', False)
self.aliases = kwargs.get('aliases', []) self.aliases = kwargs.get('aliases', [])
self.pass_context = kwargs.get('pass_context', True) self.pass_context = kwargs.get('pass_context', True)

View File

@ -203,7 +203,9 @@ class HelpFormatter:
result.append(name) result.append(name)
params = cmd.clean_params params = cmd.clean_params
if len(params) > 0: if cmd.usage:
result.append(cmd.usage)
elif len(params) > 0:
for name, param in params.items(): for name, param in params.items():
if param.default is not param.empty: if param.default is not param.empty:
# We don't want None or '' to trigger the [name=value] case and instead it should # We don't want None or '' to trigger the [name=value] case and instead it should