-
First Check
Commit to Help
Example Codeimport typer
app = typer.Typer()
get_app = typer.Typer()
app.add_typer(get_app, name="get")
@get_app.command()
def admin():
typer.echo("Admin ...")
if __name__ == "__main__":
app() DescriptionQuick preamble: If I'm asking what amounts to a stupid question, mea culpa. That said, I couldn't find any examples in the documentation or in the Discussions section on this topic. I recognize I may simply not know what to search for. The issue: My broad goal is to create a tool using the verb-noun command format as such:
I've had no issue getting to:
... but I cannot figure out / understand / conceptualize how to add that 3rd+ layer. Thank you all so much for any help. Typer has been amazing with some of my other one-off tools. Operating SystemLinux Operating System DetailsThis is not relevant. Typer Version0.7.0 Python Version3.12.0 Additional ContextBest I can offer in terms of context is this roughed-out draft design: https://github.com/gwinans/proxysqlctl/wiki/Commandline-Design-Idea(s) Ignore the repo, it's mostly me fooling around. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The tutorial has information for nested subcommands: https://typer.tiangolo.com/tutorial/subcommands/nested-subcommands/ That being said, from a code point of view it might be simpler to just go with:
Furthermore, fewer nested levels would probably make it easier for users to discover the available subcommands, too. With additional levels you need to do issue extra commands:
|
Beta Was this translation helpful? Give feedback.
The tutorial has information for nested subcommands: https://typer.tiangolo.com/tutorial/subcommands/nested-subcommands/
Unless there is some bug, it shouldn't be too difficult to extend it to more levels.
That being said, from a code point of view it might be simpler to just go with:
Furthermore, fewer nested levels would probably make it easier for users to discover the available subcommands, too.
With additional levels you need to do issue extra commands: