Skip to content

Commit 6572dc3

Browse files
authored
chore(lib): enhance error message for --folder (#462)
Closes #461.
1 parent f707b6c commit 6572dc3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
[#447](https://github.com/jeertmans/manim-slides/pull/447)
2828
- Improved issue templates.
2929
[#456](https://github.com/jeertmans/manim-slides/pull/456)
30+
- Enhancer the error message when the slides folder does not exist.
31+
[#462](https://github.com/jeertmans/manim-slides/pull/462)
3032

3133
(unreleased-fixed)=
3234
### Fixed

manim_slides/commons.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,22 @@ def callback(ctx: Context, param: Parameter, value: str) -> None:
7070

7171
def folder_path_option(function: F) -> F:
7272
"""Wrap a function to add folder path option."""
73+
74+
def callback(ctx: Context, param: Parameter, value: Path) -> Path:
75+
if not value.exists():
76+
raise click.UsageError(
77+
f"Invalid value for '--folder': Directory '{value}' does not exist. "
78+
"Did you render the animations first?",
79+
ctx=ctx,
80+
)
81+
return value
82+
7383
wrapper: Wrapper = click.option(
7484
"--folder",
7585
metavar="DIRECTORY",
7686
default=FOLDER_PATH,
77-
type=click.Path(exists=True, file_okay=False, path_type=Path),
87+
type=click.Path(file_okay=False, path_type=Path),
88+
callback=callback,
7889
help="Set slides folder.",
7990
show_default=True,
8091
)

0 commit comments

Comments
 (0)