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

17 statements  

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

1import click 1habcdefg

2import typer 1habcdefg

3 

4 

5@click.group() 1habcdefg

6def cli(): 1abcdefg

7 pass 1habcdefg

8 

9 

10@cli.command() 1habcdefg

11def initdb(): 1abcdefg

12 click.echo("Initialized the database") 1habcdefg

13 

14 

15@cli.command() 1habcdefg

16def dropdb(): 1abcdefg

17 click.echo("Dropped the database") 1habcdefg

18 

19 

20app = typer.Typer() 1habcdefg

21 

22 

23@app.command() 1habcdefg

24def sub(): 1abcdefg

25 """ 

26 A single-command Typer sub app 

27 """ 

28 print("Typer is now below Click, the Click app is the top level") 1habcdefg

29 

30 

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

32 

33cli.add_command(typer_click_object, "sub") 1habcdefg

34 

35if __name__ == "__main__": 1habcdefg

36 cli() 1habcdefg