diff --git a/src/azure/cli/_help.py b/src/azure/cli/_help.py index 2cb0f423833..56228719653 100644 --- a/src/azure/cli/_help.py +++ b/src/azure/cli/_help.py @@ -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), @@ -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) @@ -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) @@ -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'): diff --git a/src/azure/cli/application.py b/src/azure/cli/application.py index d2b710984d2..edcecfc487f 100644 --- a/src/azure/cli/application.py +++ b/src/azure/cli/application.py @@ -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.') diff --git a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py index 690867d3af8..434c36a0e76 100644 --- a/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py +++ b/src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/__init__.py @@ -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)