fix(cli): check whether project directory exists and is a directory

This commit is contained in:
jakob.scheid committed 2026-09-05 14:42:19 +02:00
1 parent 36cedb390b
commit 78e3e020be
1 file changed
+6 -4
+6 -4
View File
@@ -24,10 +24,12 @@ import argparse
import pathlib import pathlib
def existing_directory(path: str) -> pathlib.Path: def existing_directory(path: str) -> pathlib.Path:
try: _path = path
return pathlib.Path(path) path = pathlib.Path(_path)
except (FileNotFoundError, NotADirectoryError) as e: if not path.exists():
raise argparse.ArgumentTypeError(f'{e.filename}{": " + e.args[1] if len(e.args) > 1 else ""}') raise argparse.ArgumentTypeError(f'{_path}: no such file or directory')
if not path.is_dir():
raise argparse.ArgumentTypeError(f'{_path}: not a directory')
def main() -> int: def main() -> int:
argument_parser = argparse.ArgumentParser() argument_parser = argparse.ArgumentParser()