-
-
Notifications
You must be signed in to change notification settings - Fork 818
Open
Labels
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the Typer documentation, with the integrated search.
- I already searched in Google "How to X in Typer" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to Typer but to Click.
Commit to Help
- I commit to help with one of those options 👆
Example Code
# This works
import typer
app = typer.Typer(chain=True)
@app.command()
def cmd1(ctx: typer.Context, name: str = "123"):
print(f"In command 1 {name}")
@app.command()
def cmd2(ctx: typer.Context, name: str = "345"):
print(f"In command 2 {name}")
if __name__ == "__main__":
app()
# Output
In command 1 34345
In command 2 4546
## This does not work
import typer
app = typer.Typer(chain=True)
app2 = typer.Typer(chain=True)
@app.command()
def cmd1(ctx: typer.Context, name: str = "123"):
print(f"In command 1 {name}")
@app2.command()
def cmd2(ctx: typer.Context, name: str = "345"):
print(f"In command 2 {name}")
app.add_typer(app2)
if __name__ == "__main__"
app()
## Output
Error: No such command 'cmd2'Description
Add Typer objects to an app with add_typer method and try to chain commands across apps does not work. Chaining works for commands under the same app.
Operating System
macOS
Operating System Details
No response
Typer Version
0.6.1
Python Version
Python 3.8.13
Additional Context
No response
PeterMatula