Skip to content

cli_app.cli.commands.completion

cli_app.cli.commands.completion

Shell completion management commands.

install_completion

install_completion(shell=None)

Install shell completion for the current shell into its profile file.

Source code in src/cli_app/cli/commands/completion.py
@app.command("install")
def install_completion(
    shell: Annotated[
        str | None,
        typer.Option(
            "--shell",
            "-s",
            help="Target shell: bash, zsh, fish, powershell. Auto-detected if omitted.",
        ),
    ] = None,
) -> None:
    """Install shell completion for the current shell into its profile file."""
    cmd = [sys.argv[0], "--install-completion"]
    if shell:
        cmd.append(shell)
    result = subprocess.run(cmd, check=False)  # noqa: S603
    raise typer.Exit(result.returncode)

show_completion

show_completion(shell=None)

Print the shell completion script to stdout.

Source code in src/cli_app/cli/commands/completion.py
@app.command("show")
def show_completion(
    shell: Annotated[
        str | None,
        typer.Option(
            "--shell",
            "-s",
            help="Target shell: bash, zsh, fish, powershell. Auto-detected if omitted.",
        ),
    ] = None,
) -> None:
    """Print the shell completion script to stdout."""
    cmd = [sys.argv[0], "--show-completion"]
    if shell:
        cmd.append(shell)
    result = subprocess.run(cmd, check=False)  # noqa: S603
    raise typer.Exit(result.returncode)