Skip to content
Myr

Merge pull request #252 from ulope/multiple_show_default

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

Fixed exception in Option.get_help_record()

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 4a7fe69, ed0ca75 · Browse files · 2 files+19 added−1 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+19 added−1 removed

  • tests:+15 added−0 removed
  • other:+4 added−1 removed

2 files+19 added−1 removed

modified:click/core.py+4 added-1 removed
1507 unmodified lines
15081509 help = self.help or ''1510 extra = []1511 if self.default is not None and self.show_default:1512 extra.append('default: %s' % self.default)1512 extra.append('default: %s' % (1513 ', '.join('%s' % d for d in self.default)1514 if isinstance(self.default, (list, tuple))1515 else self.default, ))1516 if self.required:1517 extra.append('required')1518 if extra:1519 help = '%s[%s]' % (help and help + ' ' or '', '; '.join(extra))
113 unmodified lines
modified:tests/test_options.py+15 added
113 unmodified lines
114 assert not result.exception115 assert result.output == 'foo|bar\n'116117118def test_multiple_default_help(runner):119 @click.command()120 @click.option("--arg1", multiple=True, default=('foo', 'bar'),121 show_default=True)122 @click.option("--arg2", multiple=True, default=(1, 2), type=int,123 show_default=True)124 def cmd(arg, arg2):125 pass126127 result = runner.invoke(cmd, ['--help'])128 assert not result.exception129 assert "foo, bar" in result.output130 assert "1, 2" in result.output131132133def test_nargs_envvar(runner):134 @click.command()135 @click.option('--arg', nargs=2)136 def cmd(arg):
98 unmodified lines