Skip to main content

Module output

Module output 

Source
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

WhatMacroChannelA failed write
Data (the command’s result)outln!, out!outis the command’s error
Error reports, only in errors.rs and tui/exec.rs (a TUI session command’s error)errln!erris the command’s error
A prompt’s question, only in prompt.rserr!erris the prompt’s error
The macros above, defined in output.rswrite_errerris returned
Everything else: status, notices, warnings, “saved to”note!, Output::note_savederris 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 → stderr

Structs§

Ask
A question a command asks the TUI: the TUI shows options in a list and replies with the chosen index, or None when the user cancels.
Captured
Reads back what an Output::capture output 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.
SummaryView
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.
ProgressHook
A progress record shared between a command and the screen.
SeriesHook
The series shared between a repeating command and the screen.
ViewHook
The view a pane command left for the screen (one-shot market summary).