Skip to content

app

app = typer.Typer(rich_markup_mode='rich', invoke_without_command=True, context_settings={'help_option_names': ['-h', '--help']}) module-attribute

cli_folder_path = pathlib.Path(__file__).parent module-attribute

folder_name = file.parent.name module-attribute

full_module = f'{__package__}.{folder_name}.{py_file_name}' module-attribute

module = importlib.import_module(full_module) module-attribute

py_file_name = file.stem module-attribute

cli_command_no_args(ctx, version_requested=None)

RenderCV is a command-line tool for rendering CVs from YAML input files. For more information, see https://docs.rendercv.com.

Source code in src/rendercv/cli/app.py
@app.callback()
def cli_command_no_args(
    ctx: typer.Context,
    version_requested: Annotated[
        bool | None, typer.Option("--version", "-v", help="Show the version")
    ] = None,
):
    """RenderCV is a command-line tool for rendering CVs from YAML input files. For more
    information, see https://docs.rendercv.com.
    """
    warn_if_new_version_is_available()

    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()

warn_if_new_version_is_available()

Check PyPI for newer RenderCV version and display update notice.

Why

Users should be notified of updates for bug fixes and features. Non-blocking check on startup ensures users stay informed without interrupting workflow if check fails.

Source code in src/rendercv/cli/app.py
def warn_if_new_version_is_available() -> None:
    """Check PyPI for newer RenderCV version and display update notice.

    Why:
        Users should be notified of updates for bug fixes and features.
        Non-blocking check on startup ensures users stay informed without
        interrupting workflow if check fails.
    """
    url = "https://pypi.org/pypi/rendercv/json"
    try:
        with urllib.request.urlopen(
            url, context=ssl._create_unverified_context()
        ) as response:
            data = response.read()
            encoding = response.info().get_content_charset("utf-8")
            json_data = json.loads(data.decode(encoding))
            version_string = json_data["info"]["version"]
            latest_version = packaging.version.Version(version_string)
    except Exception:
        latest_version = None

    if latest_version is not None:
        version = packaging.version.Version(__version__)
        if version < latest_version:
            print(
                "\n[bold yellow]A new version of RenderCV is available! You are using"
                f" v{__version__}, and the latest version is v{latest_version}.[/bold"
                " yellow]\n"
            )