cape.promptutils: Useful tools for interactive CLI prompts¶
This includes a CAPE-specific autocompletion class
CfdxCompleter, which is used in cape.ui.
- cape.ui.promptutils.complete_filenames(text: str) list[str]¶
Return a tab-completion suggestion based on file names
- cape.ui.promptutils.complete_pathcmds(text: str) list[str]¶
Return a tab-completion suggestion from
$PATHexecutables
- cape.ui.promptutils.complete_xcape(text: str) list[str]¶
Return tab-completion suggestions of CAPE executables
- cape.ui.promptutils.complete_xfilenames(text: str) list[str]¶
Return a filtered list of executable file names
- cape.ui.promptutils.input_color(prompt: str, color: str = 'black') str¶
Modify built-in
input()to also set color
- cape.ui.promptutils.print_color(msg: str, color: str | list | None = None)¶
Print message using a specified ANSI color
- cape.ui.promptutils.sprintf_color(msg: str, color: str | list | None = None) str¶
Create string with optional color instructions
- cape.ui.promptutils.sprintf_color_rl(msg: str, color: str | list | None = None) str¶
Create string with color for readline input prompts
This wraps ANSI escape codes with readline’s special markers (x01 and x02) so readline can correctly calculate prompt width and handle line wrapping/cursor positioning.