Skip to content
Myr

Merge pull request #1481 from pallets/command-repr

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

Add repr for Command, Group, Option, Argument

authored by David Lord · committed by GitHub · parents 856f0b7, a566781 · Browse files · 3 files+27 added−0 removed
This commit

State

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

Diff stats

3 files+27 added−0 removed

  • tests:+18 added−0 removed
  • other:+9 added−0 removed

3 files+27 added−0 removed

modified:click/core.py+6 added
620 unmodified lines
621 context_settings = {}622 #: an optional dictionary with defaults passed to the context.623 self.context_settings = context_settings624625 def __repr__(self):626 return "<%s %s>" % (self.__class__.__name__, self.name)627628 def get_usage(self, ctx):629 raise NotImplementedError('Base commands cannot get usage')630631 def get_help(self, ctx):
763 unmodified lines
1395 self.metavar = metavar1396 self.envvar = envvar1397 self.autocompletion = autocompletion13981399 def __repr__(self):1400 return "<%s %s>" % (self.__class__.__name__, self.name)14011402 @property1403 def human_readable_name(self):1404 """Returns the human readable name of this parameter. This is the1405 same as the name for options, but the metavar for arguments.
496 unmodified lines
modified:tests/test_basic.py+18 added
21 unmodified lines
22 assert 'I EXECUTED' in result.output23 assert result.exit_code == 0242526def test_repr():27 @click.command()28 def command():29 pass3031 @click.group()32 def group():33 pass3435 @group.command()36 def subcommand():37 pass3839 assert repr(command) == '<Command command>'40 assert repr(group) == '<Group group>'41 assert repr(subcommand) == '<Command subcommand>'424344def test_return_values():45 @click.command()46 def cli():47 return 42
507 unmodified lines
modified:CHANGES.rst+3 added
56 unmodified lines
57 ``click.edit()``. :pr:`1469`58- Arguments to system calls such as the executable path passed to59 ``click.edit`` can contains spaces. :pr:`1470`60- Add ZSH completion autoloading and error handling. :issue:`1348`61- Add a repr to ``Command``, ``Group``, ``Option``, and ``Argument``,62 showing the name for friendlier debugging. :issue:`1267`636465Version 7.066-----------6768Released 2018-09-25
538 unmodified lines