Skip to content
Myr

Merge pull request #1295 from jzengg/issue-1267-add-name-to-command-repr

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

add repr to Command

authored by David Lord · committed by GitHub · parents a2d440f, f8a247a · Browse files · 3 files+28 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+28 added−0 removed

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

3 files+28 added−0 removed

modified:click/core.py+5 added
769 unmodified lines
770 more parsing to commands nested below it.771772 .. versionchanged:: 2.0773 Added the `context_settings` parameter.774 .. versionchanged:: 8.0775 Added repr showing the command name776777 :param name: the name of the command to use unless a group overrides it.778 :param context_settings: an optional dictionary with defaults that are779 passed to the context object.
36 unmodified lines
816 self.add_help_option = add_help_option817 self.hidden = hidden818 self.deprecated = deprecated819820 def __repr__(self):821 return '<%s %s>' % (self.__class__.__name__, self.name)822823 def get_usage(self, ctx):824 formatter = ctx.make_formatter()825 self.format_usage(ctx, formatter)826 return formatter.getvalue().rstrip('\n')
1035 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+5 added
4 unmodified lines
5-----------67Unreleased89- Adds a repr to Command, showing the command name for friendlier debugging. (`#1267`_, `#1295`_)1011.. _#1267: https://github.com/pallets/click/issues/126712.. _#1295: https://github.com/pallets/click/pull/1295131415Version 7.116-----------1718Unreleased
633 unmodified lines