Skip to content
Merged
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ def _check_value(self, action, value): # pylint: disable=too-many-statements, t
else:
# `command_source` indicates command values have been parsed, value is an argument
parameter = action.option_strings[0] if action.option_strings else action.dest
error_msg = "{prog}: '{value}' is not a valid value for '{param}'.".format(
prog=self.prog, value=value, param=parameter)
error_msg = "{prog}: '{value}' is not a valid value for '{param}'. Allowed values: {choice}.".format(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
error_msg = "{prog}: '{value}' is not a valid value for '{param}'. Allowed values: {choice}.".format(
error_msg = "{prog}: '{value}' is not a valid value for '{param}'. Allowed values: {choices}.".format(

prog=self.prog, value=value, param=parameter, choice=', '.join(sorted([str(x) for x in action.choices])))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need sorted? Shall we respect the order in swagger definition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The order in error message is better to be consistent with the order in help info

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I personally prefer to keep the order because some choices may be more frequently used.

candidates = difflib.get_close_matches(value, action.choices, cutoff=0.7)
az_error = InvalidArgumentValueError(error_msg)

Expand Down