diff options
| author | Frederick Muriuki Muriithi | 2025-11-19 16:01:48 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2025-11-19 16:02:55 -0600 |
| commit | dc82ee9c1ae402e26a7780c5785cbefe6c909acf (patch) | |
| tree | a1b21925a8765185e58386ee1f1c8df99862b418 /scripts/cli/validators.py | |
| parent | c039589c7fcc926254f910d94e6043c4e7e0f6d7 (diff) | |
| download | gn-uploader-dc82ee9c1ae402e26a7780c5785cbefe6c909acf.tar.gz | |
CLI: Add validator that checks path exists and is a directory.
Diffstat (limited to 'scripts/cli/validators.py')
| -rw-r--r-- | scripts/cli/validators.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/cli/validators.py b/scripts/cli/validators.py new file mode 100644 index 0000000..6d16e4c --- /dev/null +++ b/scripts/cli/validators.py @@ -0,0 +1,10 @@ +"""CLI options validators.""" +from pathlib import Path + + +def directory_exists(val: str) -> Path: + """Check that directory path specified actually exists.""" + _dir = Path(val).absolute() + if _dir.is_dir() and _dir.exists(): + return _dir + raise FileNotFoundError(f"The path '{_dir}' MUST exist and be a directory.") |
