2022-05-30

Click (Meta) Command to run a list of commands

I need to be able to trigger multiple click commands from one command on the CLI

Let's say I have a click group

@click.group()
def cli():
    pass

@cli.command()
def a():
    print("A")

@cli.command()
def b():
    print ("B")

What functionality should I add to run an ordered list of the commands like the following?

$ python -m my_cli_module a,b
A
B

The goal is that there are shared variables which get initialized for each of my commands. The init is expensive and I'd like to run the init exactly once.



No comments:

Post a Comment