Open a file and yield the corresponding (decoded) stream. Exits with error code 2 if the file cannot be opened.
(path: os.PathLike)
| 66 | |
| 67 | @contextmanager |
| 68 | def stream_file(path: os.PathLike) -> Iterator[IO[str]]: |
| 69 | """ |
| 70 | Open a file and yield the corresponding (decoded) stream. |
| 71 | |
| 72 | Exits with error code 2 if the file cannot be opened. |
| 73 | """ |
| 74 | |
| 75 | try: |
| 76 | with open(path) as stream: |
| 77 | yield stream |
| 78 | except OSError as exc: |
| 79 | print(f"Error opening env file: {exc}", file=sys.stderr) |
| 80 | sys.exit(2) |
| 81 | |
| 82 | |
| 83 | @cli.command(name="list") |
no outgoing calls
no test coverage detected
searching dependent graphs…