cli: add version mismatch warning to ls; wire ErrorSeverity in status

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I170f944127333c552e8a230972ed89d66a6a6964
This commit is contained in:
raf 2026-02-12 23:21:16 +03:00
commit 4079485179
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 90 additions and 7 deletions

View file

@ -6,7 +6,7 @@ use tokio::sync::Semaphore;
use yansi::Paint;
use crate::{
error::Result,
error::{ErrorSeverity, Result},
model::{Config, LockFile, Project},
platform::create_platform,
};
@ -36,13 +36,42 @@ pub async fn execute(
// Display results
display_update_results(&updates);
// Display errors if any
// Display errors if any, categorized by severity
if !errors.is_empty() {
println!();
println!("{}", "Errors encountered:".red());
for (project, error) in &errors {
println!(" - {}: {}", project.yellow(), error.red());
// Categorize errors by severity
let (warnings, errors_only): (Vec<_>, Vec<_>) =
errors.iter().partition(|(_, err)| {
// Network errors and "not found" are warnings (non-fatal)
err.contains("Failed to check") || err.contains("not found")
});
// Display warnings (ErrorSeverity::Warning)
if !warnings.is_empty() {
let severity = ErrorSeverity::Warning;
println!("{}", format_severity_header(severity, "Warnings"));
for (project, error) in &warnings {
println!(" - {}: {}", project.yellow(), error.dim());
}
}
// Display errors (ErrorSeverity::Error)
if !errors_only.is_empty() {
let severity = ErrorSeverity::Error;
println!("{}", format_severity_header(severity, "Errors"));
for (project, error) in &errors_only {
println!(" - {}: {}", project.yellow(), error.red());
}
}
// Log info level summary
let _info_severity = ErrorSeverity::Info;
log::info!(
"Update check completed with {} warning(s) and {} error(s)",
warnings.len(),
errors_only.len()
);
}
// Prompt to update if there are updates available
@ -52,6 +81,7 @@ pub async fn execute(
// Call update command programmatically (update all projects)
let update_args = crate::cli::UpdateArgs {
inputs: vec![],
all: true,
yes: true, // Auto-yes for status command
};
crate::cli::commands::update::execute(
@ -368,3 +398,12 @@ fn get_api_key(platform: &str) -> Option<String> {
_ => None,
}
}
/// Format severity header with appropriate color
fn format_severity_header(severity: ErrorSeverity, label: &str) -> String {
match severity {
ErrorSeverity::Error => format!("{label}:").red().to_string(),
ErrorSeverity::Warning => format!("{label}:").yellow().to_string(),
ErrorSeverity::Info => format!("{label}:").cyan().to_string(),
}
}