2016-07-02 15 views

回答

2

您可以使用@resultcallback裝飾

@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() 

>> python cli.py command 
>> Before command 
>> Command 
>> After command