Skip to content
Discussion options

You must be logged in to vote

The important change is to enter through Typer's parser, rather than calling the decorated Python function directly:

if __name__ == "__main__":
    cli()

Your test_command() call is an ordinary Python call, so an omitted argument keeps its actual Python default: the OptionInfo returned by typer.Option(...). The decorator doesn't wrap the function to parse CLI arguments on direct calls.

You can pass arguments in the debugger's launch configuration, e.g. in VS Code:

{
  "name": "Debug CLI",
  "type": "debugpy",
  "request": "launch",
  "program": "${workspaceFolder}/main.py",
  "args": ["--example-arg1", "from debugger"],
  "console": "integratedTerminal"
}

With just one registered command …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by austinhallett
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