Skip to content

Commit

Permalink
Add color to command trace (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 authored Nov 21, 2024
1 parent 191bf41 commit 816f655
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use std::{
};

use miette::Diagnostic;
use owo_colors::OwoColorize;
use thiserror::Error;
use tracing::trace;

Expand Down Expand Up @@ -289,18 +290,18 @@ impl std::fmt::Display for Cmd {
let program = self.get_program();
let mut args = self.get_args();
if let Some(arg) = args.next() {
write!(f, "{} ", program.to_string_lossy().cyan())?;
if arg != program {
write!(f, "{} ", program.to_string_lossy())?;
write!(f, "{}", arg.to_string_lossy().dimmed())?;
}
write!(f, "{}", arg.to_string_lossy())?;
}

let mut len = 0;
for arg in args {
write!(f, " {}", arg.to_string_lossy())?;
write!(f, " {}", arg.to_string_lossy().dimmed())?;
len += arg.len() + 1;
if len > 100 {
write!(f, " [...]")?;
write!(f, " {}", "[...]".dimmed())?;
break;
}
}
Expand Down

0 comments on commit 816f655

Please sign in to comment.