Expand description
§Command Output
The writers that command handlers print through. The CLI binds them to stdout and stderr. The TUI and the tests bind them to in-memory buffers, so the same handler can run in both places without printing over the terminal UI.
§The one policy
| What | Macro | Channel | A failed write |
|---|---|---|---|
| Data (the command’s result) | outln!, out! | out | is the command’s error |
Error reports, only in errors.rs and tui/exec.rs (a TUI session command’s error) | errln! | err | is the command’s error |
A prompt’s question, only in prompt.rs | err! | err | is the prompt’s error |
The macros above, defined in output.rs | write_err | err | is returned |
| Everything else: status, notices, warnings, “saved to” | note!, Output::note_saved | err | is dropped |
Data goes to out, so piped JSON and CSV stay clean. A note (“Fetching
…”, “Selected: …”, “⚠ … unavailable”) is best effort: when it cannot be
written, it must not take the place of the command’s own result, and
it does not change the exit code. Library code in scope (core) has the
same kind of best-effort line: scope::diag::notice.
The guard tests (tests/one_output_path.rs) keep errln!, err! and
write_err in the files this table names (they read the table), and
status text off outln! and out!.
ⓘ
use scope_cli::cli::output::Output;
use scope_cli::{note, outln};
let out = Output::stdio();
outln!(out, "Balance: {}", 42)?; // data → stdout
note!(out, "Fetching balances..."); // status → stderrStructs§
- Ask
- A question a command asks the TUI: the TUI shows
optionsin a list and replies with the chosen index, orNonewhen the user cancels. - Captured
- Reads back what an
Output::captureoutput received. - Output
- The output channels for one command run.
- RunProgress
- Where a repeating command is, for a screen that draws it.
- RunRecord
- One run of a repeating command, for a screen that charts it (#58).
- Series
- The runs a screen keeps, oldest first, and the metric table they read in.
- Summary
View - A market summary, for a screen that draws it (the TUI’s compact view).
Constants§
- MAX_
SERIES_ RUNS - The most runs a series keeps. Older runs are dropped.
Type Aliases§
- Asker
- The slot through which a pane command asks the TUI one question at a time.
- Progress
Hook - A progress record shared between a command and the screen.
- Series
Hook - The series shared between a repeating command and the screen.
- View
Hook - The view a pane command left for the screen (one-shot
market summary).