feat: -i interactive ratatui TUI for redbear-info and redbear-netctl
- redbear-info: -i launches ratatui dashboard (System/Hardware/Network/Integrations/Health tabs) - redbear-netctl: -i wires existing netctl-console ratatui TUI - Same -i switch convention as cub - Feature-gated behind 'tui' feature for both apps
This commit is contained in:
@@ -13,6 +13,9 @@ use toml::Value;
|
||||
#[cfg(test)]
|
||||
use std::path::Path;
|
||||
|
||||
#[cfg(feature = "tui")]
|
||||
mod tui;
|
||||
|
||||
const RESET: &str = "\x1b[0m";
|
||||
const GREEN: &str = "\x1b[32m";
|
||||
const YELLOW: &str = "\x1b[33m";
|
||||
@@ -38,6 +41,7 @@ enum OutputMode {
|
||||
Device,
|
||||
Health,
|
||||
Help,
|
||||
Tui,
|
||||
}
|
||||
|
||||
struct Options {
|
||||
@@ -523,6 +527,17 @@ fn main() {
|
||||
|
||||
fn run() -> Result<(), String> {
|
||||
let options = parse_args(env::args())?;
|
||||
|
||||
if options.mode == OutputMode::Tui {
|
||||
#[cfg(feature = "tui")]
|
||||
{
|
||||
let runtime = Runtime::from_env();
|
||||
return tui::run(&runtime).map_err(|e| format!("TUI error: {e}"));
|
||||
}
|
||||
#[cfg(not(feature = "tui"))]
|
||||
return Err("TUI support not compiled (enable 'tui' feature)".to_string());
|
||||
}
|
||||
|
||||
if options.mode == OutputMode::Help {
|
||||
print_help();
|
||||
return Ok(());
|
||||
@@ -1539,6 +1554,7 @@ where
|
||||
while let Some(arg) = args.next() {
|
||||
match arg.as_str() {
|
||||
"-v" | "--verbose" => verbose = true,
|
||||
"-i" | "--interactive" => set_output_mode(&mut mode, OutputMode::Tui, "-i")?,
|
||||
"--json" => set_output_mode(&mut mode, OutputMode::Json, "--json")?,
|
||||
"--test" => set_output_mode(&mut mode, OutputMode::Test, "--test")?,
|
||||
"--quirks" => set_output_mode(&mut mode, OutputMode::Quirks, "--quirks")?,
|
||||
|
||||
Reference in New Issue
Block a user