diff options
| author | mo8it <mo8it@proton.me> | 2024-04-25 01:56:01 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-25 01:56:01 +0200 |
| commit | 67fa01774223b08833c21baeb13bdec9e4a298a0 (patch) | |
| tree | 1892075e96fb9bb39272ae0e4e0a4b572197035d /src/run.rs | |
| parent | d8c2ab8349854cbc7f4a994c7413d266cc38bc24 (diff) | |
Use os_pipe
Diffstat (limited to 'src/run.rs')
| -rw-r--r-- | src/run.rs | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -4,20 +4,19 @@ use std::io::{self, Write}; use crate::{ app_state::{AppState, ExercisesProgress}, + exercise::OUTPUT_CAPACITY, terminal_link::TerminalFileLink, }; pub fn run(app_state: &mut AppState) -> Result<()> { let exercise = app_state.current_exercise(); - let output = exercise.run()?; + let mut output = Vec::with_capacity(OUTPUT_CAPACITY); + let success = exercise.run(&mut output)?; let mut stdout = io::stdout().lock(); - stdout.write_all(&output.stdout)?; - stdout.write_all(b"\n")?; - stdout.write_all(&output.stderr)?; - stdout.flush()?; + stdout.write_all(&output)?; - if !output.status.success() { + if !success { app_state.set_pending(app_state.current_exercise_ind())?; bail!( |
