Skip to content

Instantly share code, notes, and snippets.

@dnicolodi
Created September 19, 2021 15:30
Show Gist options
  • Save dnicolodi/1d34c0cac02a86d909eaaaca6239cae0 to your computer and use it in GitHub Desktop.
Save dnicolodi/1d34c0cac02a86d909eaaaca6239cae0 to your computer and use it in GitHub Desktop.
import click
@click.command()
@click.option('--verbose', '-v', type=int, count=True)
def main(verbose):
print(verbose)
# add an option
click.option('--times', '-n', type=int)(main)
# overwrite the callback
callback = main.callback
def foo(**kwargs):
print(kwargs)
kwargs.pop('times')
callback(**kwargs)
main.callback = foo
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment