From 78e3e020be6b13e9fb3995831f94afb7206e960f Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Sat, 5 Sep 2026 14:41:58 +0200 Subject: [PATCH] fix(cli): check whether project directory exists and is a directory --- src/jcloud_docsgen/cli.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/jcloud_docsgen/cli.py b/src/jcloud_docsgen/cli.py index 0ff0a18..b153c0a 100644 --- a/src/jcloud_docsgen/cli.py +++ b/src/jcloud_docsgen/cli.py @@ -24,10 +24,12 @@ import argparse import pathlib def existing_directory(path: str) -> pathlib.Path: - try: - return pathlib.Path(path) - except (FileNotFoundError, NotADirectoryError) as e: - raise argparse.ArgumentTypeError(f'{e.filename}{": " + e.args[1] if len(e.args) > 1 else ""}') + _path = path + path = pathlib.Path(_path) + if not path.exists(): + 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: argument_parser = argparse.ArgumentParser()