Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/azure/cli/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ 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 ''
p.short_summary = (p.short_summary if p.short_summary else '') + _get_choices_str(p)
_print_indent('{0}{1}{2}{3}'.format(p.name,
_get_column_indent(p.name + required_text,
max_name_length),
Expand Down Expand Up @@ -124,6 +125,14 @@ def _print_groups(help_file):
indent)
_print_indent('')

def _get_choices_str(p):
choice_str = ""
if p.choices:
choice_str = (' ' if p.short_summary else '') \
+ '[{}{}]'.format(', '.join(p.choices),
('; default: ' + p.default) if p.default else '')
return choice_str

def _print_examples(help_file):
indent = 0
_print_indent(L('Examples'), indent)
Expand Down Expand Up @@ -204,7 +213,9 @@ def __init__(self, delimiters, parser):
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,
default=action.default))

def _load_from_data(self, data):
super(CommandHelpFile, self)._load_from_data(data)
Expand All @@ -228,14 +239,16 @@ def _load_from_data(self, data):
self.parameters = loaded_params


class HelpParameter(object): #pylint: disable=too-few-public-methods
def __init__(self, param_name, description, required):
class HelpParameter(object): #pylint: disable=too-few-public-methods, too-many-instance-attributes
def __init__(self, param_name, description, required, choices=None, default=None): #pylint: disable=too-many-arguments
self.name = param_name
self.required = required
self.type = 'string'
self.short_summary = description
self.long_summary = ''
self.value_sources = []
self.choices = choices
self.default = default

def update_from_data(self, data):
if self.name != data.get('name'):
Expand Down
3 changes: 2 additions & 1 deletion src/azure/cli/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def _register_builtin_arguments(parser):
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"')
default='list',
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.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def exists_container(args):
@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)
Expand Down