Coverage for docs_src / launch / tutorial002.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
1from pathlib import Path 1abcdefghij
3import typer 1abcdefghij
5APP_NAME = "my-super-cli-app" 1abcdefghij
7app = typer.Typer() 1abcdefghij
10@app.command() 1abcdefghij
11def main(): 1abcdefghij
12 app_dir = typer.get_app_dir(APP_NAME) 1abcdefghij
13 app_dir_path = Path(app_dir) 1abcdefghij
14 app_dir_path.mkdir(parents=True, exist_ok=True) 1abcdefghij
15 config_path: Path = Path(app_dir) / "config.json" 1abcdefghij
16 if not config_path.is_file(): 1abcdefghij
17 config_path.write_text('{"version": "1.0.0"}') 1abcdefghij
18 config_file_str = str(config_path) 1abcdefghij
19 print("Opening config directory") 1abcdefghij
20 typer.launch(config_file_str, locate=True) 1abcdefghij
23if __name__ == "__main__": 1abcdefghij
24 app() 1abcdefghij