clap-tui
clap-tui turns a clap CLI into an interactive terminal UI while preserving the original command-line interface. You can keep clap as the source of truth, collect input in a terminal form, and then continue your normal application dispatch with the selected typed command value.
It reduces trial-and-error for complex CLIs by making commands, flags, and values easier to explore before execution. It also improves discoverability without changing the CLI behavior your existing scripts and docs already rely on.
This crate was heavily inspired by Trogon. clap-tui is a community crate and is not an official clap project.

Add clap-tui to your project
[]
= { = "4.5", = ["derive", "env"] }
= "0.1.0"
Minimum supported Rust version: 1.88.
Quick start
Add a Tui subcommand and delegate to Tui::run().
The recommended 0.1.0 integration model is an explicit Command::Tui dispatch branch that calls Tui::<Command>::hide_entrypoint("tui")?.run().
use Parser;
use Tui;
Tui::<T>::run() returns:
Some(T)when the user submits a valid commandNonewhen the user cancels before submissionErr(TuiError)for runtime failures or clap-driven flows such as help and version handling
See TuiError for the detailed error taxonomy.
Choose an entrypoint
- Use
Tui::<T>::run()(recommended) when you want typed results from a derive-based clap parser. - Use
TuiApp::from_command(...)when you already have a hand-builtclap::Commandor need the lower-level untyped argv orArgMatchesflow.
Supported customization seams
TuiConfigcontrols theme, layout, key bindings, and initial command selection.TuiApp::with_runtime(...)and the exportedRuntimeevent types support custom event loops or embedding into existing runtimes.TuiConfig.start_commandlets you preselect a command path such asbuild::release.
Internal reducers, projections, render helpers, and other support modules are not stable extension points.
Feature flags
mouseis enabled by default and turns on mouse capture plus mouse-driven controls.
Terminal expectations
clap-tuirequires an interactive terminal that supports raw mode and an alternate screen.- The default
CrosstermRuntimerestores the terminal before returning, including when the user cancels. - Mouse interactions require the default
mousefeature. - Validation stays inside the TUI flow: invalid forms show inline feedback instead of returning partially parsed values.
Example guide
simpleshows minimalCommand::Tuisetup with the entrypoint hidden from the rendered TUI.showcaseshows a realistic, readable CLI with a small nested config area.subcommandsshows typed dispatch across command trees.clap_featuresis the diagnostic compatibility fixture for the fullTuiApp::from_command(...)surface. It launches the TUI directly, expects an interactive terminal, and is not intended for non-interactive--helpusage.
Release verification
Maintainers can run ./scripts/verify.sh for the same formatting, linting, test, and package-surface checks that the GitHub verify workflow enforces. See docs/release-readiness.md for the routine release runbook, docs/publishing-setup.md for one-time publishing setup, and docs/release-troubleshooting.md for troubleshooting and local simulation notes.
Theme presets
use ;
let mut config = default;
config.theme = from_preset;
Available presets:
ThemePreset::CalmDark(default)ThemePreset::HighContrastDarkThemePreset::Light
Controls
Tabswitches focusShift+Tabcycles tabs?toggles the Help tab/opens command searchCtrl+Rruns the current selectionCtrl+Enterruns when supported by the terminalCtrl+Cexits without running- typing edits the focused field