[Python] Click (Meta) Command to run a list of commands

Discussão em 'Python' iniciado por Stack, Junho 19, 2025.

  1. Stack

    Stack Membro Participativo

    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.

    Continue reading...

Compartilhe esta Página