Skip to content
Myr

Merge pull request #1014 from rhgrant10/feature/574

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

Fixes #574

authored by David Lord · committed by GitHub · parents 084da90, 344269a · Browse files · 2 files+12 added−6 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+12 added−6 removed

  • tests:+9 added−0 removed
  • other:+3 added−6 removed

2 files+12 added−6 removed

modified:click/core.py+3 added-6 removed
1349 unmodified lines
1350 self.default = default1351 self.is_eager = is_eager1352 self.metavar = metavar1353 self.envvar = envvar1354 self.autocompletion = autocompletion1354 self.autocompletion = autocompletion13551356 @property1357 def human_readable_name(self):1358 """Returns the human readable name of this parameter. This is the
22 unmodified lines
13811382 def add_to_parser(self, parser, ctx):1383 pass138413851385 def consume_value(self, ctx, opts):1386 value = opts.get(self.name)1387 if value is None:1388 value = self.value_from_envvar(ctx)
441 unmodified lines
1830 raise TypeError('Could not determine name for argument')1831 if len(decls) == 1:1832 name = arg = decls[0]1833 name = name.replace('-', '_').lower()1835 elif len(decls) == 2:1836 name, arg = decls1834 else:1838 raise TypeError('Arguments take exactly one or two '1839 'parameter declarations, got %d' % len(decls))1835 raise TypeError('Arguments take exactly one '1836 'parameter declaration, got %d' % len(decls))1837 return name, [arg], []18381839 def get_usage_pieces(self, ctx):1840 return [self.make_metavar()]
11 unmodified lines
modified:tests/test_arguments.py+9 added
1# -*- coding: utf-8 -*-2import pytest3import click4from click._compat import PY256
280 unmodified lines
287288 result = runner.invoke(cmd, ['3'])289 assert result.exception is not None290 assert 'argument a takes 2 values' in result.output291292293def test_multiple_param_decls_not_allowed(runner):294 with pytest.raises(TypeError):295 @click.command()296 @click.argument('x', click.Choice(['a', 'b']))297 def copy(x):298 click.echo(x)