Python Click: Having the group execute code AFTER a command
问题 I have a click.group() defined, with about 10 commands in it. I understand how to use a group to run code before the code in the command, but I also want to run some code AFTER each command is run. Is that possible with click? 回答1: You can use @resultcallback decorator @click.group() def cli(): click.echo('Before command') @cli.resultcallback() def process_result(result, **kwargs): click.echo('After command') @cli.command() def command(): click.echo('Command') if __name__ == '__main__': cli()