cape.tui Textual-based user interface to CAPE

OpenCode-style interactive terminal user interface to CAPE, built on the optional textual package and launched with:

$ cape tui

It provides the same core features as cape.ui – CAPE-aware tab-completion and a dedicated history file – inside a persistent app with a scroll log, a pinned dark composer, and context below the prompt. Ctrl-P opens a picker for the built-in TUI commands:

  • In-process CAPE commands

    Commands starting with cape, pycart, pyfun, etc. run in-process using cape.cfdx.cli.main(), with output streamed into the log; other commands run as subprocesses.

  • Interruptions and prompts

    Ctrl-C (or ESC) interrupts the running command, and interactive CAPE prompts mount as clickable widgets above the editor.

  • TUI meta-commands

    Commands starting with : are handled by the TUI itself: :help [<cmd>], :history [<n>], :!N, :status, :cd <dir> (plain cd also works), :pwd, :clear, and :exit / :quit.

See cape.tui.tuiapp for the app itself and cape.tui.tuiutils for the render helpers.

cape.tui.main(cls: type | None = None) → Tuple[int, dict]

Main Textual-based interactive TUI function

Call:
>>> ierr, stats = main(cls)
Inputs:
cls: {None} | type

cape.argread.ArgReader subtype for completions and :help; defaults to cape.cfdx.cli.CfdxFrontDesk

Outputs:
ierr: int

Return code

stats: dict

Information about results of commands run

  • commands: int number of commands run

  • failures: int number of failed commands

  • tui_commands: int number of TUI meta-cmds

  • duration: float session wall time (sec)

  • json_files: tuple of loaded JSON paths, least to most recently used

  • last_json_file: str | None most recent absolute JSON path

  • last_json_display_file: str | None path displayed relative to the controller’s root

cape.tui.run_app(app, title: str = 'CAPE TUI summary') → Tuple[int, dict]

Run a CAPE Textual app with shared prompt/history lifecycle