Skip to content
v0.1.3

Version Command API Reference

This section documents the internals of the version command in Bijux CLI.

bijux_cli.commands.version

Implements the version command for the Bijux CLI.

This module reports the CLI's version and runtime environment information. The output is machine-readable, available in JSON or YAML, and is designed to be safe for automation and scripting by adhering to a strict output contract and ASCII hygiene.

Output Contract
  • Success: {"version": str}
  • Verbose: Adds {"python": str, "platform": str, "timestamp": float}.
  • Error: {"error": str, "code": int}
Exit Codes
  • 0: Success.
  • 1: Internal or fatal error.
  • 2: CLI argument, flag, or format error.
  • 3: ASCII or encoding error.

version

version(
    ctx: Context,
    quiet: bool = Option(
        False, "-q", "--quiet", help=HELP_QUIET
    ),
    verbose: bool = Option(
        False, "-v", "--verbose", help=HELP_VERBOSE
    ),
    fmt: str = Option(
        "json", "-f", "--format", help=HELP_FORMAT
    ),
    pretty: bool = Option(
        True, "--pretty/--no-pretty", help=HELP_NO_PRETTY
    ),
    debug: bool = Option(
        False, "-d", "--debug", help=HELP_DEBUG
    ),
) -> None

Defines the entrypoint and logic for the bijux version command.

This function orchestrates the version reporting process by validating flags and then using the shared new_run_command helper to build and emit the final payload.

Parameters:

  • ctx (Context) –

    The Typer context for the CLI.

  • quiet (bool, default: Option(False, '-q', '--quiet', help=HELP_QUIET) ) –

    If True, suppresses all output; the exit code is the primary indicator of the outcome.

  • verbose (bool, default: Option(False, '-v', '--verbose', help=HELP_VERBOSE) ) –

    If True, includes Python, platform, and timestamp details in the output payload.

  • fmt (str, default: Option('json', '-f', '--format', help=HELP_FORMAT) ) –

    The output format, either "json" or "yaml". Defaults to "json".

  • pretty (bool, default: Option(True, '--pretty/--no-pretty', help=HELP_NO_PRETTY) ) –

    If True, pretty-prints the output for human readability.

  • debug (bool, default: Option(False, '-d', '--debug', help=HELP_DEBUG) ) –

    If True, enables debug diagnostics, implying verbose and pretty.

Returns:

  • None ( None ) –

Raises:

  • SystemExit

    Always exits with a contract-compliant status code and payload upon completion or error.

Source code in src/bijux_cli/commands/version.py
@version_app.callback(invoke_without_command=True)
def version(
    ctx: typer.Context,
    quiet: bool = typer.Option(False, "-q", "--quiet", help=HELP_QUIET),
    verbose: bool = typer.Option(False, "-v", "--verbose", help=HELP_VERBOSE),
    fmt: str = typer.Option("json", "-f", "--format", help=HELP_FORMAT),
    pretty: bool = typer.Option(True, "--pretty/--no-pretty", help=HELP_NO_PRETTY),
    debug: bool = typer.Option(False, "-d", "--debug", help=HELP_DEBUG),
) -> None:
    """Defines the entrypoint and logic for the `bijux version` command.

    This function orchestrates the version reporting process by validating
    flags and then using the shared `new_run_command` helper to build and
    emit the final payload.

    Args:
        ctx (typer.Context): The Typer context for the CLI.
        quiet (bool): If True, suppresses all output; the exit code is the
            primary indicator of the outcome.
        verbose (bool): If True, includes Python, platform, and timestamp
            details in the output payload.
        fmt (str): The output format, either "json" or "yaml". Defaults to "json".
        pretty (bool): If True, pretty-prints the output for human readability.
        debug (bool): If True, enables debug diagnostics, implying `verbose`
            and `pretty`.

    Returns:
        None:

    Raises:
        SystemExit: Always exits with a contract-compliant status code and
            payload upon completion or error.
    """
    if ctx.invoked_subcommand:
        return

    DIContainer.current().resolve(EmitterProtocol)
    DIContainer.current().resolve(TelemetryProtocol)
    command = "version"

    fmt_lower = validate_common_flags(fmt, command, quiet)

    new_run_command(
        command_name=command,
        payload_builder=lambda include: _build_payload(include),
        quiet=quiet,
        verbose=verbose,
        fmt=fmt_lower,
        pretty=pretty,
        debug=debug,
    )