зеркало из https://github.com/microsoft/azure-cli.git
Support displaying choice lists in help
This commit is contained in:
Родитель
62261f8fb1
Коммит
b57dae29ea
|
@ -78,6 +78,8 @@ def print_arguments(help_file):
|
|||
for p in sorted(help_file.parameters, key=lambda p: str(not p.required) + p.name):
|
||||
indent = 1
|
||||
required_text = required_tag if p.required else ''
|
||||
if p.choices:
|
||||
p.short_summary = (p.short_summary + ' ' if p.short_summary else '') + str(p.choices)
|
||||
_print_indent('{0}{1}{2}{3}'.format(p.name,
|
||||
_get_column_indent(p.name + required_text,
|
||||
max_name_length),
|
||||
|
@ -204,7 +206,8 @@ class CommandHelpFile(HelpFile): #pylint: disable=too-few-public-methods
|
|||
for action in [a for a in parser._actions if a.help != argparse.SUPPRESS]: # pylint: disable=protected-access
|
||||
self.parameters.append(HelpParameter(' '.join(sorted(action.option_strings)),
|
||||
action.help,
|
||||
required=action.required))
|
||||
required=action.required,
|
||||
choices=action.choices))
|
||||
|
||||
def _load_from_data(self, data):
|
||||
super(CommandHelpFile, self)._load_from_data(data)
|
||||
|
@ -229,13 +232,14 @@ class CommandHelpFile(HelpFile): #pylint: disable=too-few-public-methods
|
|||
|
||||
|
||||
class HelpParameter(object): #pylint: disable=too-few-public-methods
|
||||
def __init__(self, param_name, description, required):
|
||||
def __init__(self, param_name, description, required, choices=None):
|
||||
self.name = param_name
|
||||
self.required = required
|
||||
self.type = 'string'
|
||||
self.short_summary = description
|
||||
self.long_summary = ''
|
||||
self.value_sources = []
|
||||
self.choices = choices
|
||||
|
||||
def update_from_data(self, data):
|
||||
if self.name != data.get('name'):
|
||||
|
|
|
@ -138,7 +138,7 @@ class Application(object):
|
|||
parser.add_argument('--subscription', dest='_subscription_id', help=argparse.SUPPRESS)
|
||||
parser.add_argument('--output', '-o', dest='_output_format',
|
||||
choices=['list', 'json', 'tsv'],
|
||||
help='Output format of type "list", "json" or "tsv"')
|
||||
help='Output format')
|
||||
# The arguments for verbosity don't get parsed by argparse but we add it here for help.
|
||||
parser.add_argument('--verbose', dest='_log_verbosity_verbose',
|
||||
help='Increase logging verbosity. Use --debug for full debug logs.')
|
||||
|
|
|
@ -301,7 +301,7 @@ blob_types_str = ' '.join(blob_types.keys())
|
|||
@command_table.option(**PARAMETER_ALIASES['container_name'])
|
||||
@command_table.option(**PARAMETER_ALIASES['blob_name'])
|
||||
@command_table.option('--type', required=True, choices=blob_types.keys(),
|
||||
help=L('type of blob to upload ({})'.format(blob_types_str)))
|
||||
help=L('type of blob to upload'))
|
||||
@command_table.option('--upload-from', required=True,
|
||||
help=L('local path to upload from'))
|
||||
@command_table.option_set(STORAGE_DATA_CLIENT_ARGS)
|
||||
|
|
Загрузка…
Ссылка в новой задаче