diff --git a/src/main.rs b/src/main.rs index 7a9272c..d636886 100644 --- a/src/main.rs +++ b/src/main.rs @@ -190,7 +190,7 @@ fn main() -> Result<()> { let (message_rx, command_request_tx) = init_message_passing(); // Run the actual application - let app = App::new(message_rx, command_request_tx, text_orig); + let mut app = App::new(message_rx, command_request_tx, text_orig); enable_raw_mode()?; let mut stdout = io::stdout(); execute!( @@ -202,7 +202,7 @@ fn main() -> Result<()> { let backend = CrosstermBackend::new(stdout); let mut terminal = Terminal::new(backend)?; - let res = run_app(&mut terminal, app); + let res = run_app(&mut terminal, &mut app); // Restore terminal disable_raw_mode()?; @@ -219,6 +219,8 @@ fn main() -> Result<()> { if let Some(res) = res { std::io::stderr().write_all(res.as_bytes())?; std::io::stderr().write_all(b"\n")?; + // TODO: I do not want to collect the whole thing into a vec + app.command_options.read().command_result.as_ref().map(|r| std::io::stdout().write_all(&r.stdout.bytes().collect::>())).transpose()?; } Ok(()) @@ -248,7 +250,7 @@ fn init_message_passing() -> (Receiver, Sender) { #[allow(clippy::too_many_lines)] #[cfg_attr(debug_assertions, instrument(skip(terminal, app)))] -fn run_app(terminal: &mut Terminal, mut app: App) -> Result> { +fn run_app(terminal: &mut Terminal, app: &mut App) -> Result> { // When starting the app, ensure the command runs at least once { let mut command_options = app.command_options.write();