Skip to main content
Feature: tui

Commander is a terminal UI for browsing and running tests or examples. It is a convenient way to explore the project without memorizing every example path.

Info

What you will learn

  • How to build and launch Commander.
  • How to navigate and filter the list.
  • What kinds of files Commander discovers, and what it runs for each.

Build and launch#

Commander is an opt-in feature. The default build leaves out the terminal UI (ratatui and crossterm), so enable the tui feature:

Note

An sbrs built without the feature still has the subcommand, but it only prints the following message and exits with status 2.

Run it from the project root: Commander looks for tests/ and examples/ in the current directory.

KeyAction
↓ / ↑ or j / kMove selection (wraps around at either end)
EnterRun selected item
/ or fFilter list
rRefresh list (rescan tests/ and examples/)
qQuit

In filter mode, type to narrow the list (a case-insensitive match on the file name), Backspace deletes a character, Enter keeps the filter and returns to the list, and Esc clears it. The result popup closes with Esc, Enter or q.

What it runs#

Commander discovers:

  • *.rs files directly inside examples/, shown as [example].
  • *.rs files directly inside tests/, shown as [test].

It does not descend into subfolders, and it does not look for scenarios or any other file type.

Select an item and press Enter. Commander runs cargo test --test <name> for a test or cargo run --example <name> for an example, waits for it to finish (the UI does not redraw meanwhile), and shows a popup: PASS: <name> with a green border, or FAIL: <name> (exit code: ...) with a red one, followed by the last 20 lines of the combined standard output and standard error.

Tips#

  • Use the filter key (/) to quickly find a test by name.
  • Commander passes no flags of its own to Cargo. The child process inherits Commander’s environment, so set SB_* variables (for example SB_HEADLESS) before launching it, or use sbrs test for per-run flags.
  • A test or example that needs an opt-in Cargo feature (for instance the examples that require gui) cannot be built from Commander, because it cannot pass --features. Use sbrs test --example <name> --features gui.
  • If a file is missing from the list, check that it sits directly in tests/ or examples/ and ends in .rs, then press r.

See also#

The same feature builds two more terminal apps: