Coverage for docs_src/parameter_types/path/tutorial001.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1from pathlib import Path 1abcdefgh
2from typing import Optional 1abcdefgh
4import typer 1abcdefgh
7def main(config: Optional[Path] = typer.Option(None)): 1abcdefgh
8 if config is None: 1abcdefgh
9 print("No config file") 1abcdefgh
10 raise typer.Abort() 1abcdefgh
11 if config.is_file(): 1abcdefgh
12 text = config.read_text() 1abcdefgh
13 print(f"Config file contents: {text}") 1abcdefgh
14 elif config.is_dir(): 1abcdefgh
15 print("Config is a directory, will use all its config files") 1abcdefgh
16 elif not config.exists(): 1abcdefgh
17 print("The config doesn't exist") 1abcdefgh
20if __name__ == "__main__": 1abcdefgh
21 typer.run(main) 1abcdefgh