First check
Description
How can I use Classes app in Typer and specific instance methods as commands?
The more easy question can be how can I implement the below code using class. Please note not all instance methods shall be a command.
from typing import Optional
import typer
app = typer.Typer()
@app.command()
def hello(name: Optional[str] = None):
if name:
typer.echo(f"Hello {name}")
else:
typer.echo("Hello World!")
@app.command()
def bye(name: Optional[str] = None):
if name:
typer.echo(f"Bye {name}")
else:
typer.echo("Goodbye!")
if __name__ == "__main__":
app()
Additional context
I checked #306 (comment) but it has a static method.
Regards.
First check
Description
How can I use Classes app in Typer and specific instance methods as commands?
The more easy question can be how can I implement the below code using class. Please note not all instance methods shall be a command.
Additional context
I checked #306 (comment) but it has a static method.
Regards.