diff options
| author | Mo <76752051+mo8it@users.noreply.github.com> | 2024-04-25 14:43:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-25 14:43:28 +0200 |
| commit | 88f27a53771a49a4e541627b84cc5dc7ab6f7357 (patch) | |
| tree | eba5401fd370e85cf597771b34a042eb5ae65475 /src/run.rs | |
| parent | d8c2ab8349854cbc7f4a994c7413d266cc38bc24 (diff) | |
| parent | 1f1a62d83ef9398a1a31c904a2ef6d81f5455e59 (diff) | |
Merge pull request #1959 from rust-lang/output
Improve output
Diffstat (limited to 'src/run.rs')
| -rw-r--r-- | src/run.rs | 18 |
1 files changed, 9 insertions, 9 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!( @@ -26,11 +25,12 @@ pub fn run(app_state: &mut AppState) -> Result<()> { ); } - stdout.write_fmt(format_args!( - "{}{}\n", + writeln!( + stdout, + "{}{}", "✓ Successfully ran ".green(), exercise.path.green(), - ))?; + )?; if let Some(solution_path) = app_state.current_solution_path()? { println!( |
