Coverage for docs_src/subcommands/name_help/tutorial008.py: 100%

11 statements  

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

1import typer 1habcdefg

2 

3app = typer.Typer() 1habcdefg

4 

5 

6def old_callback(): 1habcdefg

7 """ 

8 Old callback help. 

9 """ 

10 

11 

12users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") 1habcdefg

13 

14 

15def new_users(): 1habcdefg

16 """ 

17 I have the highland! Create some users. 

18 """ 

19 

20 

21app.add_typer( 1habcdefg

22 users_app, 

23 callback=new_users, 

24 name="cake-sith-users", 

25 help="Unlimited powder! Eh, users.", 

26) 

27 

28 

29@users_app.callback("call-users", help="Help from callback for users.") 1habcdefg

30def users(): 1abcdefg

31 """ 

32 Manage users in the app. 

33 """ 

34 

35 

36@users_app.command() 1habcdefg

37def create(name: str): 1habcdefg

38 print(f"Creating user: {name}") 1habcdefg

39 

40 

41if __name__ == "__main__": 1habcdefg

42 app() 1habcdefg