[Python] Click: How to propagate the exit code back to the group

Discussão em 'Python' iniciado por Stack, Janeiro 31, 2025.

  1. Stack

    Stack Membro Participativo

    I have a script which use click.group to provide sub commands. Each of the sub command might pass or fail. How do I propagate the exit code from the sub commands back to main?

    import click
    import sys

    @click.group()
    def main():
    # How do I get the exit code from `get`?
    sys.exit(0) # use that exit code here


    @main.command()
    def get():
    exit_code = 1
    # How do I send the exit code back to main?

    Continue reading...

Compartilhe esta Página