Skip to content

Commit

Permalink
Move value source display to short summary. Fixes Azure#634 (Azure#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
BurtBiel authored Sep 2, 2016
1 parent f3a803b commit ab9a636
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 5 additions & 6 deletions src/azure/cli/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def print_arguments(help_file):
possible_values_index = short_summary.find(' Possible values include')
short_summary = short_summary[0:possible_values_index
if possible_values_index >= 0 else len(short_summary)]
short_summary += _get_choices_defaults_str(p)
short_summary += _get_choices_defaults_sources_str(p)
short_summary = short_summary.strip()

if p.group_name != last_group_name:
Expand All @@ -114,9 +114,6 @@ def print_arguments(help_file):
if p.long_summary:
_print_indent('{0}'.format(p.long_summary.rstrip()), indent)

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

if p.long_summary or p.value_sources:
print('')
return indent
Expand Down Expand Up @@ -165,12 +162,14 @@ def _print_items(items):
_print_indent('Commands:')
_print_items(subcommands)

def _get_choices_defaults_str(p):
def _get_choices_defaults_sources_str(p):
choice_str = ' Allowed values: {0}.'.format(', '.join(sorted([str(x) for x in p.choices]))) \
if p.choices else ''
default_str = ' Default: {0}.'.format(p.default) \
if p.default and p.default != argparse.SUPPRESS else ''
return '{0}{1}'.format(choice_str, default_str)
value_sources_str = ' Values from: {0}.'.format(', '.join(p.value_sources)) \
if p.value_sources else ''
return '{0}{1}{2}'.format(choice_str, default_str, value_sources_str)

def _print_examples(help_file):
indent = 0
Expand Down
6 changes: 2 additions & 4 deletions src/azure/cli/tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@ def test_handler():
--foobar2 -fb2 [Required]: One line partial sentence.
Paragraph(s).
--foobar -fb : One line partial sentence.
--foobar -fb : One line partial sentence. Values from: az vm list, default.
Text, markdown, etc.
Values from: az vm list, default.
--foobar3 -fb3 : The foobar3.
Expand Down Expand Up @@ -280,9 +279,8 @@ def test_handler():
--foobar2 -fb2 [Required]: One line partial sentence.
Paragraph(s).
--foobar -fb : One line partial sentence.
--foobar -fb : One line partial sentence. Values from: az vm list, default.
Text, markdown, etc.
Values from: az vm list, default.
Global Arguments
Expand Down

0 comments on commit ab9a636

Please sign in to comment.