cape.tui.tuiutils: Render helpers for the CAPE TUI¶
This module provides the presentation helpers for cape.tui,
the Textual-based interactive terminal user interface to CAPE. These
functions build Rich renderables (tables, panels) which the app
writes to its scroll log or prints to the terminal on exit.
- cape.tui.tuiutils.banner_panel(histfile: str | None = None) Panel¶
Build the CAPE TUI startup banner
- Call:
>>> panel = banner_panel(histfile=None)
- Inputs:
- histfile: {
None} |str Name of command history file
- histfile: {
- Outputs:
- panel:
rich.panel.Panel Startup banner with host info and key hints
- panel:
- cape.tui.tuiutils.cmd_help_panel(cmdname: str, subcls: type, cls: type) Panel¶
Build a Rich help panel for a single CAPE sub-command
- Call:
>>> panel = cmd_help_panel(cmdname, subcls, cls)
- Inputs:
- cmdname:
str Name of command
- subcls:
type cape.argread.ArgReaderfor cmdname- cls:
type cape.argread.ArgReaderfor front desk
- cmdname:
- Outputs:
- panel:
rich.panel.Panel Panel with description, aliases, and options table
- panel:
- cape.tui.tuiutils.cmd_table(cls: type) Table¶
Build a Rich table of all CAPE sub-commands
- Call:
>>> table = cmd_table(cls)
- Inputs:
- cls:
type cape.argread.ArgReadersubtype
- cls:
- Outputs:
- table:
rich.table.Table Table of CAPE commands, descriptions, and aliases
- table:
- cape.tui.tuiutils.get_dirname(path: str | None = None) str¶
Get the last two folders of a path, as in
cape.ui
- cape.tui.tuiutils.get_tui_histfile() str¶
Get the name of the CAPE TUI history file
The file is controlled by the TUIHistoryFile option from the user’s
~/.capeconfig.json(or the$CAPE_TUI_HISTORY_FILEenvironment variable). Relative paths are joined with the CAPE CacheDir.- Call:
>>> histfile = get_tui_histfile()
- Outputs:
- histfile:
str Name of TUI command history file
- histfile:
- cape.tui.tuiutils.history_table(history: list, n: int = 25) Table¶
Build a table of recently-run commands
- cape.tui.tuiutils.meta_help_table() Table¶
Build table of TUI meta-commands
- Call:
>>> table = meta_help_table()
- Outputs:
- table:
rich.table.Table Table of TUI meta-commands and their descriptions
- table:
- cape.tui.tuiutils.session_stats_panel(stats: dict, histfile: str | None = None, title: str = 'CAPE TUI session') Panel¶
Build a panel summarizing the TUI session
- Call:
>>> panel = session_stats_panel(stats, histfile=None) >>> panel = session_stats_panel(stats, histfile, title="Bye")
- Inputs:
- Outputs:
- panel:
rich.panel.Panel Session summary panel
- panel: