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
42 changes: 0 additions & 42 deletions azure-cli.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,6 @@
<Compile Include="command_modules\azure-cli-storage\setup.py" />
<Compile Include="command_modules\azure-cli-taskhelp\azure\cli\command_modules\taskhelp\__init__.py" />
<Compile Include="command_modules\azure-cli-taskhelp\setup.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\credentials.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\exceptions.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\basic_dependency.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\dependency.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_extended.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_parameter_virtual_network_ip_address_prefix.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_properties_extended.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_vm.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\parameters_link.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\provider.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\provider_resource_type.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\template_link.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\vm_creation_client_enums.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\vm_operations.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\version.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\vm_creation_client.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\command_specs.py">
<SubType>Code</SubType>
</Compile>
Expand All @@ -161,9 +141,6 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\setup.py" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -220,11 +197,6 @@
<Folder Include="command_modules\azure-cli-vm\azure\cli\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\" />
<Folder Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\recordings\" />
</ItemGroup>
Expand All @@ -251,20 +223,6 @@
<Content Include="command_modules\azure-cli-storage\requirements.txt" />
<Content Include="command_modules\azure-cli-taskhelp\requirements.txt" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\aliases.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\azuredeploy.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\ExistingStorageAccount.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\ExistingVNet.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\NewStorageAccount.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\NewVNet.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_existing_dns_none.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_new_dns_new.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_new_dns_none.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\nic_ip_none_dns_none.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_existing_password.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_existing_sshkey.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_none_password.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\nested_templates\vm_none_sshkey.json" />
<Content Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\swagger_create_vm.json" />
<Content Include="command_modules\azure-cli-vm\requirements.txt" />
</ItemGroup>
<ItemGroup>
Expand Down
24 changes: 19 additions & 5 deletions src/azure/cli/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ def print_arguments(help_file):
required_tag = L(' [Required]')
max_name_length = max(len(p.name) + (len(required_tag) if p.required else 0)
for p in help_file.parameters)
for p in sorted(help_file.parameters, key=lambda p: str(not p.required) + p.name):
last_group_name = None
for p in sorted(help_file.parameters,
key=lambda p: str(p.group_name or 'A')
+ 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)
if p.group_name != last_group_name:
if p.group_name:
print('')
print(p.group_name)
last_group_name = p.group_name
_print_indent('{0}{1}{2}{3}'.format(p.name,
_get_column_indent(p.name + required_text,
max_name_length),
Expand All @@ -92,7 +100,6 @@ def print_arguments(help_file):
_print_indent('{0}'.format(p.long_summary.rstrip()), indent)

if p.value_sources:
_print_indent('')
_print_indent(L("Values from: {0}").format(', '.join(p.value_sources)), indent)

if p.long_summary or p.value_sources:
Expand All @@ -105,7 +112,7 @@ def _print_header(help_file):
_print_indent(L('Command') if help_file.type == 'command' else L('Group'), indent)

indent += 1
_print_indent('{0}{1}'.format(help_file.command,
_print_indent('{0}{1}'.format('az ' + help_file.command,
': ' + help_file.short_summary
if help_file.short_summary
else ''),
Expand Down Expand Up @@ -138,6 +145,7 @@ def _get_choices_str(p):

def _print_examples(help_file):
indent = 0
print('')
_print_indent(L('Examples'), indent)

for e in help_file.examples:
Expand Down Expand Up @@ -218,7 +226,11 @@ def __init__(self, delimiters, parser):
action.help,
required=action.required,
choices=action.choices,
default=action.default))
default=action.default,
group_name=action.container.description))

help_param = next(p for p in self.parameters if p.name == '--help -h')
help_param.group_name = 'Global Arguments'

def _load_from_data(self, data):
super(CommandHelpFile, self)._load_from_data(data)
Expand All @@ -243,7 +255,8 @@ def _load_from_data(self, data):


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
def __init__(self, param_name, description, required, choices=None, #pylint: disable=too-many-arguments
default=None, group_name=None):
self.name = param_name
self.required = required
self.type = 'string'
Expand All @@ -252,6 +265,7 @@ def __init__(self, param_name, description, required, choices=None, default=None
self.value_sources = []
self.choices = choices
self.default = default
self.group_name = group_name

def update_from_data(self, data):
if self.name != data.get('name'):
Expand Down
26 changes: 15 additions & 11 deletions src/azure/cli/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def __init__(self, configuration):
azure.cli.extensions.register_extensions(self)

self.global_parser = AzCliCommandParser(prog='az', add_help=False)
self.raise_event(self.GLOBAL_PARSER_CREATED, self.global_parser)
global_group = self.global_parser.add_argument_group('global', 'Global Arguments')
self.raise_event(self.GLOBAL_PARSER_CREATED, global_group)

self.parser = AzCliCommandParser(prog='az', parents=[self.global_parser])
self.raise_event(self.COMMAND_PARSER_CREATED, self.parser)
Expand Down Expand Up @@ -134,17 +135,20 @@ def _enable_autocomplete(parser):
argcomplete.autocomplete(parser)

@staticmethod
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'],
default='list',
help='Output format')
def _register_builtin_arguments(global_group):
global_group.add_argument('--subscription', dest='_subscription_id', help=argparse.SUPPRESS)
global_group.add_argument('--output', '-o', dest='_output_format',
choices=['list', 'json', '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.')
parser.add_argument('--debug', dest='_log_verbosity_debug',
help='Increase logging verbosity to show all debug logs.')
global_group.add_argument('--verbose', dest='_log_verbosity_verbose',
help='Increase logging verbosity.'
' Use --debug for full debug logs.',
action='store_true')
global_group.add_argument('--debug', dest='_log_verbosity_debug',
help='Increase logging verbosity to show all debug logs.',
action='store_true')

def _handle_builtin_arguments(self, args):
self.configuration.output_format = args._output_format #pylint: disable=protected-access
Expand Down
6 changes: 3 additions & 3 deletions src/azure/cli/extensions/query.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import collections

def _register_global_parameter(parser):
def _register_global_parameter(global_group):
# Let the program know that we are adding a parameter --query
parser.add_argument('--query', dest='_jmespath_query', metavar='JMESPATH',
help='JMESPath query string. See http://jmespath.org/ for more information and examples.') # pylint: disable=line-too-long
global_group.add_argument('--query', dest='_jmespath_query', metavar='JMESPATH',
help='JMESPath query string. See http://jmespath.org/ for more information and examples.') # pylint: disable=line-too-long

def register(application):
def handle_query_parameter(args):
Expand Down
Loading