Skip to content
Myr

Merge pull request #1000 from dawran6/issue-202

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Wrap click.Choice's missing message

authored by Dan Sully · committed by GitHub · parents 4861896, 7214afe · Browse files · 2 files+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−3 removed

  • tests:+5 added−2 removed
  • other:+1 added−1 removed

2 files+6 added−3 removed

modified:click/types.py+1 added-1 removed
145 unmodified lines
146 def get_metavar(self, param):147 return '[%s]' % '|'.join(self.choices)148149 def get_missing_message(self, param):150 return 'Choose from %s.' % ', '.join(self.choices)150 return 'Choose from:\n\t%s.' % ',\n\t'.join(self.choices)151152 def convert(self, value, param, ctx):153 # Exact match154 if value in self.choices:
456 unmodified lines
modified:tests/test_options.py+5 added-2 removed
304 unmodified lines
305 click.echo(foo)306307 result = runner.invoke(cmd)308 assert result.exit_code == 2309 assert 'Error: Missing option "--foo". Choose from foo, bar.' \310 in result.output309 error, separator, choices = result.output.partition('Choose from')310 assert 'Error: Missing option "--foo". ' in error311 assert 'Choose from' in separator312 assert 'foo' in choices313 assert 'bar' in choices314315316def test_case_insensitive_choice(runner):317 @click.command()
159 unmodified lines