1. import click
    2. _global_options = [
    3. click.option('-v', '--verbose', count=True, default=0, help='Verbose output.'),
    4. click.option('-n', '--dry-run', is_flag=True, default=False, help='Dry-run mode.')
    5. ]
    6. def common_options(func):
    7. for option in reversed(_global_options):
    8. func = option(func)
    9. return func
    10. # Standard way using it as a decorator
    11. @click.group()
    12. @common_options
    13. def cli():
    14. pass
    15. # Using it as a function
    16. @click.group()
    17. def cli():
    18. pass
    19. common_options(cli)