Completion
clak.comp.completion
Register a Python executable for use with the argcomplete module.
To perform the registration, source the output of this script in your bash shell (quote the output to avoid interpolation).
Example:
$ eval "$(register-python-argcomplete my-favorite-script.py)"
For Tcsh
$ eval `register-python-argcomplete --shell tcsh my-favorite-script.py`
For Fish
$ register-python-argcomplete --shell fish my-favourite-script.py > ~/.config/fish/my-favourite-script.py.fish
CompCmdRender
Bases: CompRenderCmdMixin
, Parser
Command completion renderer class.
Combines the CompRenderCmdMixin with the base Parser to create a class that can render command completion code. This class provides the core functionality for generating shell completion scripts for command-line tools.
Key features: - Generates shell completion code for bash/tcsh/fish - Supports external completion scripts - Configurable executable names - Default completion behavior
Source code in clak/comp/completion.py
CompRenderCmdMixin
Bases: CompRenderMixin
Completion command support
Source code in clak/comp/completion.py
cli_run(ctx, **kwargs)
Command completion support mixin.
Adds command completion support to parsers by providing arguments to configure shell completion behavior:
- --no-defaults: Disable fallback to readline defaults (bash only)
- --complete-arguments: Custom completion arguments (bash only)
- --shell: Target shell (bash, zsh, tcsh, fish, powershell)
- --executable: Name of executable to complete
The mixin generates the appropriate shell completion code when run. Supports bash (default), zsh, tcsh, fish and powershell shells.
Example
my-app completion # Outputs bash completion code my-app completion --shell zsh # Outputs zsh completion code
Source code in clak/comp/completion.py
CompRenderMixin
Completion support Methods
Source code in clak/comp/completion.py
print_completion_stdout(args)
Print completion script to stdout.
Generates and outputs shell completion code for the specified executable using argcomplete. The completion script enables tab completion for commands and arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args
|
SimpleNamespace
|
Namespace containing completion configuration: executable: Name of executable to enable completion for use_defaults: Whether to fallback to readline defaults (bash only) shell: Target shell (bash, zsh, tcsh, fish, powershell) complete_arguments: Optional arguments to pass to complete command external_argcomplete_script: Optional external completion script |
required |
Source code in clak/comp/completion.py
CompRenderOptMixin
Bases: CompRenderMixin
Completion options support mixin.
Adds option completion support to parsers by providing a --completion flag that generates shell completion code. When used, outputs the appropriate completion code for the configured shell.
The mixin adds: - --completion flag to generate shell completion code - Default completion behavior configuration - Shell-specific completion code generation
Supports bash (default), zsh, tcsh, fish and powershell shells.
Source code in clak/comp/completion.py
cli_run(ctx, **kwargs)
Completion options support mixin.
Adds option completion support to parsers by providing: - --completion flag to generate shell completion code - Default completion behavior configuration - Shell-specific completion code generation
The mixin adds a --completion argument that when used will output the appropriate shell completion code. It supports: - bash (default) - zsh - tcsh - fish - powershell
Example
my-app --completion # Outputs bash completion code my-app --completion --shell zsh # Outputs zsh completion code