MCPcopy Create free account
hub / github.com/cargo-lambda/cargo-lambda / run_subcommand

Function run_subcommand

crates/cargo-lambda-cli/src/main.rs:289–330  ·  view source on GitHub ↗
(lambda: Lambda, color: Color)

Source from the content-addressed store, hash-verified

287}
288
289async 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
332fn error_hook(color: Option<&Color>) -> ErrorHook {
333 let ansi = match color {

Callers 1

mainFunction · 0.85

Calls 8

print_versionFunction · 0.85
print_helpFunction · 0.85
newFunction · 0.85
xray_layerFunction · 0.85
is_ansiMethod · 0.80
initMethod · 0.80
to_lowercaseMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected