diff --git a/crates/brioche/src/format.rs b/crates/brioche/src/format.rs index 7ff2974..9f258cf 100644 --- a/crates/brioche/src/format.rs +++ b/crates/brioche/src/format.rs @@ -26,11 +26,17 @@ pub async fn format(args: FormatArgs) -> anyhow::Result { for project_path in args.project { match project_format(&reporter, &project_path, args.check).await { Err(err) => { - println!( - "Error occurred while formatting project '{project_path}': {err}", - project_path = project_path.display(), - err = err - ); + reporter.emit(superconsole::Lines::from_multiline_string( + &format!( + "Error occurred while formatting project '{project_path}': {err}", + project_path = project_path.display(), + err = err + ), + superconsole::style::ContentStyle { + foreground_color: Some(superconsole::style::Color::Red), + ..superconsole::style::ContentStyle::default() + }, + )); error_result = Some(()); } @@ -81,35 +87,44 @@ async fn project_format( if !check { if !files.is_empty() { - println!( - "The following files of project '{project_path}' have been formatted:\n{files}", - project_path = project_path.display(), - files = files - .iter() - .map(|file| format!("- {}", file.display())) - .collect::>() - .join("\n") - ); + reporter.emit(superconsole::Lines::from_multiline_string( + &format!( + "The following files of project '{project_path}' have been formatted:\n{files}", + project_path = project_path.display(), + files = files + .iter() + .map(|file| format!("- {}", file.display())) + .collect::>() + .join("\n") + ), + superconsole::style::ContentStyle::default(), + )); } Ok(true) } else if files.is_empty() { - println!( - "All files of project '{project_path}' are formatted", - project_path = project_path.display() - ); + reporter.emit(superconsole::Lines::from_multiline_string( + &format!( + "All files of project '{project_path}' are formatted", + project_path = project_path.display() + ), + superconsole::style::ContentStyle::default(), + )); Ok(true) } else { - println!( - "The following files of project '{project_path}' are not formatted:\n{files}", - project_path = project_path.display(), - files = files - .iter() - .map(|file| format!("- {}", file.display())) - .collect::>() - .join("\n") - ); + reporter.emit(superconsole::Lines::from_multiline_string( + &format!( + "The following files of project '{project_path}' are not formatted:\n{files}", + project_path = project_path.display(), + files = files + .iter() + .map(|file| format!("- {}", file.display())) + .collect::>() + .join("\n") + ), + superconsole::style::ContentStyle::default(), + )); Ok(false) } diff --git a/crates/brioche/src/publish.rs b/crates/brioche/src/publish.rs index 05c5399..4b90cfa 100644 --- a/crates/brioche/src/publish.rs +++ b/crates/brioche/src/publish.rs @@ -36,37 +36,39 @@ pub async fn publish(args: PublishArgs) -> anyhow::Result { } let checked = brioche_core::script::check::check(&brioche, &projects, project_hash).await?; + + guard.shutdown_console().await; + let check_results = checked.ensure_ok(brioche_core::script::check::DiagnosticLevel::Warning); - match check_results { + Ok(match check_results { Ok(()) => { println!("No errors found 🎉"); - } - Err(diagnostics) => { - diagnostics.write(&brioche.vfs, &mut std::io::stdout())?; - return Ok(ExitCode::FAILURE); - } - } - guard.shutdown_console().await; - - let response = - brioche_core::publish::publish_project(&brioche, &projects, project_hash, true).await?; + let response = + brioche_core::publish::publish_project(&brioche, &projects, project_hash, true) + .await?; - if response.tags.is_empty() { - println!("Project already up to date: {} {}", name, version); - } else { - println!("🚀 Published project {} {}", name, version); - println!(); - println!("Updated tags:"); - for tag in &response.tags { - let status = if tag.previous_hash.is_some() { - "updated" + if response.tags.is_empty() { + println!("Project already up to date: {} {}", name, version); } else { - "new" - }; - println!(" {} {} ({status})", tag.name, tag.tag); - } - } + println!("🚀 Published project {} {}", name, version); + println!(); + println!("Updated tags:"); + for tag in &response.tags { + let status = if tag.previous_hash.is_some() { + "updated" + } else { + "new" + }; + println!(" {} {} ({status})", tag.name, tag.tag); + } + } - Ok(ExitCode::SUCCESS) + ExitCode::SUCCESS + } + Err(diagnostics) => { + diagnostics.write(&brioche.vfs, &mut std::io::stdout())?; + ExitCode::FAILURE + } + }) }