(lambda: Lambda, color: Color)
| 287 | } |
| 288 | |
| 289 | async fn run_subcommand(lambda: Lambda, color: Color) -> Result<()> { |
| 290 | if lambda.version { |
| 291 | return print_version(); |
| 292 | } |
| 293 | |
| 294 | let subcommand = match lambda.subcommand { |
| 295 | None => return print_help(), |
| 296 | Some(subcommand) => subcommand, |
| 297 | }; |
| 298 | |
| 299 | let log_directive = if lambda.verbose == 0 { |
| 300 | std::env::var("RUST_LOG").unwrap_or_else(|_| "cargo_lambda=info".into()) |
| 301 | } else if lambda.verbose == 1 { |
| 302 | "cargo_lambda=debug".into() |
| 303 | } else { |
| 304 | "cargo_lambda=trace".into() |
| 305 | }; |
| 306 | |
| 307 | let fmt = tracing_subscriber::fmt::layer() |
| 308 | .with_target(false) |
| 309 | .without_time() |
| 310 | .with_ansi(color.is_ansi()); |
| 311 | |
| 312 | let subscriber = tracing_subscriber::registry() |
| 313 | .with(tracing_subscriber::EnvFilter::new(log_directive)) |
| 314 | .with(fmt); |
| 315 | |
| 316 | if let LambdaSubcommand::Watch(w) = &*subcommand { |
| 317 | subscriber.with(xray_layer(w)).init(); |
| 318 | } else { |
| 319 | subscriber.init(); |
| 320 | } |
| 321 | |
| 322 | subcommand |
| 323 | .run( |
| 324 | &color.to_lowercase(), |
| 325 | lambda.global, |
| 326 | lambda.context, |
| 327 | lambda.admerge, |
| 328 | ) |
| 329 | .await |
| 330 | } |
| 331 | |
| 332 | fn error_hook(color: Option<&Color>) -> ErrorHook { |
| 333 | let ansi = match color { |
no test coverage detected