Skip to content
Myr

Added support for return values from command callbacks.

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

authored by Armin Ronacher · committed by Armin Ronacher · parent a939618 · Browse files · 3 files+12 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

3 files+12 added−1 removed

  • tests:+10 added−0 removed
  • other:+2 added−1 removed

3 files+12 added−1 removed

modified:click/core.py+1 added-1 removed
734 unmodified lines
735 """Given a context, this invokes the attached callback (if it exists)736 in the right way.737 """738 if self.callback is not None:739 ctx.invoke(self.callback, **ctx.params)739 return ctx.invoke(self.callback, **ctx.params)740741742class MultiCommand(Command):743 """A multi command is the basic implementation of a command that
718 unmodified lines
modified:tests/test_basic.py+10 added
21 unmodified lines
22 assert 'I EXECUTED' in result.output23 assert result.exit_code == 0242526def test_return_values():27 @click.command()28 def cli():29 return 423031 with cli.make_context('foo', []) as ctx:32 rv = cli.invoke(ctx)33 assert rv is 42343536def test_basic_group(runner):37 @click.group()38 def cli():39 """This is the root."""
360 unmodified lines
modified:CHANGES+1 added
27 unmodified lines
28- label passed to `progressbar` is no longer rendered with29 whitespace stripped.30- added a way to disable the standalone mode of the `main`31 method on a Click command to be able to handle errors better.32- added support for returning values from command callbacks.3334Version 2.635-----------36
111 unmodified lines