Coverage for docs_src / launch / tutorial002_py39.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-02-09 12:36 +0000

1from pathlib import Path 1abcdefgh

2 

3import typer 1abcdefgh

4 

5APP_NAME = "my-super-cli-app" 1abcdefgh

6 

7app = typer.Typer() 1abcdefgh

8 

9 

10@app.command() 1abcdefgh

11def main(): 1abcdefgh

12 app_dir = typer.get_app_dir(APP_NAME) 1abcdefgh

13 app_dir_path = Path(app_dir) 1abcdefgh

14 app_dir_path.mkdir(parents=True, exist_ok=True) 1abcdefgh

15 config_path: Path = Path(app_dir) / "config.json" 1abcdefgh

16 if not config_path.is_file(): 1abcdefgh

17 config_path.write_text('{"version": "1.0.0"}') 1abcdefgh

18 config_file_str = str(config_path) 1abcdefgh

19 print("Opening config directory") 1abcdefgh

20 typer.launch(config_file_str, locate=True) 1abcdefgh

21 

22 

23if __name__ == "__main__": 1abcdefgh

24 app() 1abcdefgh