feat(irtt-cli): add optional tui output mode
This commit is contained in:
6 files changed
+2210
-6
No files matched your search
@@ -17,10 +17,13 @@ doc = false
|
||||
[features]
|
||||
default = ["stats"]
|
||||
stats = ["dep:irtt-stats"]
|
||||
tui = ["stats", "dep:ratatui", "dep:crossterm"]
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.6.1", features = ["derive"] }
|
||||
crossterm = { version = "0.28.1", optional = true }
|
||||
ctrlc = "3.5.2"
|
||||
irtt-client.workspace = true
|
||||
irtt-proto.workspace = true
|
||||
irtt-stats = { workspace = true, optional = true }
|
||||
ratatui = { version = "0.29.0", optional = true }
|
||||
@@ -89,7 +89,7 @@ pub struct CliArgs {
|
||||
#[arg(long)]
|
||||
pub loose: bool,
|
||||
|
||||
/// Output format: human, simple, machine, or rtt-us.
|
||||
/// Output format.
|
||||
#[arg(long, value_enum, default_value_t = OutputMode::Human)]
|
||||
pub output: OutputMode,
|
||||
|
||||
@@ -201,6 +201,9 @@ pub enum OutputMode {
|
||||
Simple,
|
||||
/// RTT microseconds only.
|
||||
RttUs,
|
||||
/// TUI dashboard with live cumulative statistics.
|
||||
#[cfg(feature = "tui")]
|
||||
Tui,
|
||||
}
|
||||
|
||||
impl OutputMode {
|
||||
@@ -320,6 +323,8 @@ pub fn format_event(event: &ClientEvent, mode: OutputMode) -> Option<String> {
|
||||
OutputMode::Human => Some(format_human_event(event, None)),
|
||||
OutputMode::Machine => Some(format_machine(event)),
|
||||
OutputMode::Simple => Some(format_simple(event)),
|
||||
#[cfg(feature = "tui")]
|
||||
OutputMode::Tui => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ use irtt_client::{Client, ClientEvent, OpenOutcome, RecvBudget};
|
||||
#[cfg(all(test, feature = "stats"))]
|
||||
use irtt_client::ClientTimestamp;
|
||||
|
||||
#[cfg(feature = "tui")]
|
||||
mod tui;
|
||||
#[cfg(feature = "tui")]
|
||||
use tui::run_tui;
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
use irtt_stats::{StatsCollector, StatsConfig};
|
||||
|
||||
@@ -66,6 +71,8 @@ fn run(args: CliArgs, shutdown_requested: &AtomicBool) -> Result<(), Box<dyn std
|
||||
OutputMode::Human | OutputMode::Machine | OutputMode::Simple | OutputMode::RttUs => {
|
||||
run_stream(args, shutdown_requested)
|
||||
}
|
||||
#[cfg(feature = "tui")]
|
||||
OutputMode::Tui => run_tui(args, shutdown_requested),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user