diff --git a/rendercv/cli/commands.py b/rendercv/cli/commands.py index da8b2e60..c5463de7 100644 --- a/rendercv/cli/commands.py +++ b/rendercv/cli/commands.py @@ -57,7 +57,7 @@ def cli_command_render( "-o", help="Name of the output folder.", ), - ] = None, + ] = "rendercv_output", latex_path: Annotated[ Optional[str], typer.Option( @@ -105,7 +105,7 @@ def cli_command_render( "-nomd", help="Don't generate the Markdown and HTML file.", ), - ] = None, + ] = False, dont_generate_html: Annotated[ bool, typer.Option( @@ -113,7 +113,7 @@ def cli_command_render( "-nohtml", help="Don't generate the HTML file.", ), - ] = None, + ] = False, dont_generate_png: Annotated[ bool, typer.Option( @@ -121,7 +121,7 @@ def cli_command_render( "-nopng", help="Don't generate the PNG file.", ), - ] = None, + ] = False, # This is a dummy argument for the help message for # extra_data_model_override_argumets: _: Annotated[ @@ -144,6 +144,7 @@ def cli_command_render( # dictionary for command line arguments: cli_args = { + "use_local_latex_command": use_local_latex_command, "output_folder_name": output_folder_name, "latex_path": latex_path, "pdf_path": pdf_path, @@ -154,6 +155,20 @@ def cli_command_render( "no_html": dont_generate_html, "no_png": dont_generate_png, } + + # Create the default values for the cli_args: + cli_args_default = { + "use_local_latex_command": None, + "output_folder_name": "rendercv_output", + "latex_path": None, + "pdf_path": None, + "markdown_path": None, + "html_path": None, + "png_path": None, + "no_markdown": False, + "no_html": False, + "no_png": False, + } # change the current working directory to the input file's directory (because # the template overrides are looked up in the current working directory): @@ -182,9 +197,7 @@ def cli_command_render( ) # update the data of the rendercv settings: render_cv_settings = data_as_a_dict.get("rendercv_settings", dict()) - render_cv_settings = utilities.build_rendercv_settings( - render_cv_settings, cli_args - ) + render_cv_settings = utilities.build_rendercv_settings(render_cv_settings, cli_args, cli_args_default) # update the data model with the rendercv settings: data_as_a_dict["rendercv_settings"] = render_cv_settings @@ -193,9 +206,7 @@ def cli_command_render( data_as_a_dict ) - output_directory = ( - pathlib.Path.cwd() / data_model.rendercv_settings.output_folder_name - ) + output_directory = pathlib.Path(data_model.rendercv_settings.output_folder_name) progress.finish_the_current_step() diff --git a/rendercv/cli/utilities.py b/rendercv/cli/utilities.py index 62c563ba..150bff39 100644 --- a/rendercv/cli/utilities.py +++ b/rendercv/cli/utilities.py @@ -265,6 +265,7 @@ def parse_render_command_override_arguments( def build_rendercv_settings( dictionary: dict, command_line_arguments: dict[str, str], + command_line_arguments_default_values: dict[str, str], ) -> dict[str, str]: """Build the RenderCV settings dictionary by combining the dictionary and the command line arguments. @@ -278,6 +279,16 @@ def build_rendercv_settings( """ # Combine the dictionary and the command line arguments if the values are not None: for key, value in command_line_arguments.items(): - if value is not None: - dictionary = set_or_update_a_value(dictionary, key, value) # type: ignore + # check if the key is present in the both command line arguments and the default values: + if key in command_line_arguments_default_values: + default_value = command_line_arguments_default_values[key] + if value != default_value: + dictionary = set_or_update_a_value(dictionary, key, value) + else: + # The key is not present in the default values, set the value: + # throw an error reporting this + raise ValueError( + f"The key ({key}) is not present in the default values of the command" + " line arguments!" + ) return dictionary diff --git a/rendercv/data/models/rendercv_settings.py b/rendercv/data/models/rendercv_settings.py index addbd931..dfa25fa4 100644 --- a/rendercv/data/models/rendercv_settings.py +++ b/rendercv/data/models/rendercv_settings.py @@ -26,6 +26,16 @@ class RenderCVSettings(pydantic.BaseModel): ' value is "rendercv_output".' ), ) + + + use_local_latex_command: Optional[str] = pydantic.Field( + default=None, + title="Local LaTeX Command", + description=( + "The command to compile the LaTeX file to a PDF file. The default value is" + ' "pdflatex".' + ), + ) pdf_path: Optional[str] = pydantic.Field( default=None,