| 330 | } |
| 331 | |
| 332 | fn error_hook(color: Option<&Color>) -> ErrorHook { |
| 333 | let ansi = match color { |
| 334 | Some(color) => color.is_ansi(), |
| 335 | None => { |
| 336 | let color = std::env::var("CARGO_LAMBDA_COLOR"); |
| 337 | Color::try_from(color.as_deref().unwrap_or("auto")) |
| 338 | .expect("invalid color option, must be auto, always, or never") |
| 339 | .is_ansi() |
| 340 | } |
| 341 | }; |
| 342 | Box::new(move |_| { |
| 343 | Box::new(miette::MietteHandlerOpts::new() |
| 344 | .terminal_links(true) |
| 345 | .footer("Was this behavior unexpected?\nStart a thread in https://github.com/cargo-lambda/cargo-lambda/discussions".into()) |
| 346 | .color(ansi) |
| 347 | .build()) |
| 348 | }) |
| 349 | } |
| 350 | |
| 351 | fn run_zig(zig: Zig) -> Result<()> { |
| 352 | miette::set_hook(error_hook(None))?; |