mirror of
https://github.com/rendercv/rendercv.git
synced 2025-12-23 21:47:55 -05:00
CLI improvements
This commit is contained in:
@@ -15,13 +15,13 @@ app = typer.Typer(
|
||||
rich_markup_mode="rich",
|
||||
# to make `rendercv --version` work:
|
||||
invoke_without_command=True,
|
||||
no_args_is_help=True,
|
||||
context_settings={"help_option_names": ["-h", "--help"]},
|
||||
)
|
||||
|
||||
|
||||
@app.callback()
|
||||
def cli_command_no_args(
|
||||
ctx: typer.Context,
|
||||
version_requested: Annotated[
|
||||
bool | None, typer.Option("--version", "-v", help="Show the version")
|
||||
] = None,
|
||||
@@ -33,6 +33,10 @@ def cli_command_no_args(
|
||||
|
||||
if version_requested:
|
||||
print(f"RenderCV v{__version__}")
|
||||
elif ctx.invoked_subcommand is None:
|
||||
# No command was provided, show help
|
||||
print(ctx.get_help())
|
||||
raise typer.Exit()
|
||||
|
||||
|
||||
def warn_if_new_version_is_available() -> None:
|
||||
|
||||
@@ -154,5 +154,7 @@ def run_rendercv(
|
||||
)
|
||||
)
|
||||
)
|
||||
except OSError as e:
|
||||
progress.print_user_error(RenderCVUserError(message=f"OS Error: {e}"))
|
||||
except RenderCVUserValidationError as e:
|
||||
progress.print_validation_errors(e.validation_errors)
|
||||
|
||||
@@ -32,7 +32,12 @@ def run_function_if_file_changes(file_path: pathlib.Path, function: Callable):
|
||||
return
|
||||
|
||||
with contextlib.suppress(typer.Exit):
|
||||
self.function()
|
||||
try:
|
||||
self.function()
|
||||
except Exception as e:
|
||||
# This means an unhandled error occurred in the function.
|
||||
# Don't surpress it
|
||||
raise e
|
||||
|
||||
event_handler = EventHandler(function)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user