Coverage for docs_src/using_click/tutorial003.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 18:26 +0000

1import click 1habcdefg

2import typer 1habcdefg

3 

4app = typer.Typer() 1habcdefg

5 

6 

7@app.command() 1habcdefg

8def top(): 1abcdefg

9 """ 

10 Top level command, form Typer 

11 """ 

12 print("The Typer app is at the top level") 1habcdefg

13 

14 

15@app.callback() 1habcdefg

16def callback(): 1abcdefg

17 """ 

18 Typer app, including Click subapp 

19 """ 

20 

21 

22@click.command() 1habcdefg

23@click.option("--name", prompt="Your name", help="The person to greet.") 1habcdefg

24def hello(name): 1abcdefg

25 """Simple program that greets NAME for a total of COUNT times.""" 

26 click.echo(f"Hello {name}!") 1habcdefg

27 

28 

29typer_click_object = typer.main.get_command(app) 1habcdefg

30 

31typer_click_object.add_command(hello, "hello") 1habcdefg

32 

33if __name__ == "__main__": 1habcdefg

34 typer_click_object() 1habcdefg