Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure '--ids' validation failure prints usage string #1271

Merged
merged 1 commit into from
Nov 9, 2016
Merged

Ensure '--ids' validation failure prints usage string #1271

merged 1 commit into from
Nov 9, 2016

Conversation

tjprescott
Copy link
Member

Fixes #1254.

The validator for the --ids parameter raised a CLIError if it failed. After change #1037, CLIErrors thrown from a validator no longer cause the usage string to be printed. Thus, to ensure that a usage string is thrown when --ids usage is incorrect, this error was changed to a ValueError, which is the most common approach used by existing validators.

@tjprescott tjprescott changed the title Fix Issue #1254 Ensure '--ids' validation failure prints usage string Nov 8, 2016
Copy link
Member

@derekbekoe derekbekoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Added 1 question.

@@ -144,7 +144,7 @@ def required_values_validator(namespace):

if errors:
missing_required = ' '.join((arg.options_list[0] for arg in errors))
raise CLIError('({} | {}) are required'.format(missing_required, '--ids'))
raise ValueError('({} | {}) are required'.format(missing_required, '--ids'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the message '({} | {}) are required' shown in the usage statement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks exactly like it did before #1037:

usage: az vm show [-h] [--output {json,tsv,list,table,jsonc}] [--verbose]
                  [--debug] [--query JMESPATH]
                  [--resource-group RESOURCE_GROUP_NAME]
                  [--ids RESOURCE_ID [RESOURCE_ID ...]] [--name NAME]
                  [--expand EXPAND]
az vm show: error: (--resource-group --name | --ids) are required

@tjprescott tjprescott merged commit 14a924e into Azure:master Nov 9, 2016
@tjprescott tjprescott deleted the FixUsageString branch November 9, 2016 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants