Skip to content

I want to add the command "help" to my CLI (as a command and not an option) #833

Discussion options

You must be logged in to vote

I finally figured it out.
When I did this:

@app.command(name="help")
def help(ctx: typer.Context):
    print(ctx.get_help())

I was getting the help for this command which is "help".
So I had to go back one level (using context.parent) to get what I needed:

@app.command(name="help")
def help(ctx: typer.Context):
    print(ctx.parent.get_help())

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ismailbenhallam
Comment options

@ismailbenhallam
Comment options

Answer selected by ismailbenhallam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants