Skip to content

Commit

Permalink
Merge pull request #1000 from dawran6/issue-202
Browse files Browse the repository at this point in the history
Wrap click.Choice's missing message
  • Loading branch information
Dan Sully authored May 16, 2018
2 parents 4861896 + 7214afe commit f27a8df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion click/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_metavar(self, param):
return '[%s]' % '|'.join(self.choices)

def get_missing_message(self, param):
return 'Choose from %s.' % ', '.join(self.choices)
return 'Choose from:\n\t%s.' % ',\n\t'.join(self.choices)

def convert(self, value, param, ctx):
# Exact match
Expand Down
7 changes: 5 additions & 2 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,11 @@ def cmd(foo):

result = runner.invoke(cmd)
assert result.exit_code == 2
assert 'Error: Missing option "--foo". Choose from foo, bar.' \
in result.output
error, separator, choices = result.output.partition('Choose from')
assert 'Error: Missing option "--foo". ' in error
assert 'Choose from' in separator
assert 'foo' in choices
assert 'bar' in choices


def test_case_insensitive_choice(runner):
Expand Down

0 comments on commit f27a8df

Please sign in to comment.