I have two Python CLI tools which share a set of common click.options. At the moment, the common options are duplicated:
@click.command()
@click.option('--foo', is_flag=True)
@click.option('--bar', is_flag=True)
@click.option('--unique-flag-1', is_flag=True)
def command_one():
pass
@click.command()
@click.option('--foo', is_flag=True)
@click.option('--bar', is_flag=True)
@click.option('--unique-flag-2', is_flag=True)
def command_two():
pass
Is it possible to extract the common options in to a single decorator that can be applied to each function?
my_tool say greeting name
wheregreeting
andname
are arguments you would want to make sure that in your function you put thename
argument before thegreeting
argument in the list. – Ballast