Fix colors (#927)
- Re-enable error colors - Color argument count mismatch usage string
This commit is contained in:
parent
27cf2b96df
commit
7efb82f4cb
25
src/error.rs
25
src/error.rs
@ -200,11 +200,11 @@ impl<'src> ColorDisplay for Error<'src> {
|
|||||||
match self {
|
match self {
|
||||||
ArgumentCountMismatch {
|
ArgumentCountMismatch {
|
||||||
recipe,
|
recipe,
|
||||||
parameters,
|
|
||||||
found,
|
found,
|
||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
} => {
|
..
|
||||||
|
} =>
|
||||||
if min == max {
|
if min == max {
|
||||||
let expected = min;
|
let expected = min;
|
||||||
write!(
|
write!(
|
||||||
@ -234,11 +234,6 @@ impl<'src> ColorDisplay for Error<'src> {
|
|||||||
Count("argument", *found),
|
Count("argument", *found),
|
||||||
max
|
max
|
||||||
)?;
|
)?;
|
||||||
}
|
|
||||||
write!(f, "\nusage:\n just {}", recipe)?;
|
|
||||||
for param in parameters {
|
|
||||||
write!(f, " {}", param.color_display(color))?;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Backtick { output_error, .. } => match output_error {
|
Backtick { output_error, .. } => match output_error {
|
||||||
OutputError::Code(code) => {
|
OutputError::Code(code) => {
|
||||||
@ -604,6 +599,22 @@ impl<'src> ColorDisplay for Error<'src> {
|
|||||||
|
|
||||||
write!(f, "{}", color.message().suffix())?;
|
write!(f, "{}", color.message().suffix())?;
|
||||||
|
|
||||||
|
if let ArgumentCountMismatch {
|
||||||
|
recipe, parameters, ..
|
||||||
|
} = self
|
||||||
|
{
|
||||||
|
writeln!(f)?;
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}:\n just {}",
|
||||||
|
color.message().paint("usage"),
|
||||||
|
recipe
|
||||||
|
)?;
|
||||||
|
for param in parameters {
|
||||||
|
write!(f, " {}", param.color_display(color))?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(token) = self.context() {
|
if let Some(token) = self.context() {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
write!(f, "{}", token.color_display(color.error()))?;
|
write!(f, "{}", token.color_display(color.error()))?;
|
||||||
|
@ -30,7 +30,7 @@ pub fn run() -> Result<(), i32> {
|
|||||||
})
|
})
|
||||||
.map_err(|error| {
|
.map_err(|error| {
|
||||||
if !verbosity.quiet() {
|
if !verbosity.quiet() {
|
||||||
eprintln!("{}", error.color_display(color));
|
eprintln!("{}", error.color_display(color.stderr()));
|
||||||
}
|
}
|
||||||
error.code().unwrap_or(EXIT_FAILURE)
|
error.code().unwrap_or(EXIT_FAILURE)
|
||||||
})
|
})
|
||||||
|
@ -23,3 +23,19 @@ test! {
|
|||||||
",
|
",
|
||||||
status: EXIT_FAILURE,
|
status: EXIT_FAILURE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn argument_count_mismatch() {
|
||||||
|
Test::new()
|
||||||
|
.justfile("foo a b:")
|
||||||
|
.args(&["foo"])
|
||||||
|
.stderr(
|
||||||
|
"
|
||||||
|
error: Recipe `foo` got 0 arguments but takes 2
|
||||||
|
usage:
|
||||||
|
just foo a b
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.status(EXIT_FAILURE)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user