forked from cargo-lambda/cargo-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
48 lines (44 loc) · 1.21 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use std::boxed::Box;
use cargo_zigbuild::Zig;
use clap::{Parser, Subcommand};
use miette::{miette, Result};
mod build;
mod invoke;
mod metadata;
mod progress;
mod start;
mod toolchain;
mod zig;
#[derive(Parser)]
#[clap(name = "cargo")]
#[clap(bin_name = "cargo")]
#[clap(global_setting(clap::AppSettings::DeriveDisplayOrder))]
enum App {
#[clap(subcommand)]
Lambda(Box<Lambda>),
#[clap(subcommand, hide = true)]
Zig(Zig),
}
/// Cargo Lambda is a CLI to work with AWS Lambda functions locally
#[derive(Clone, Debug, Subcommand)]
#[clap(version)]
pub enum Lambda {
/// Build AWS Lambda functions compiled with zig as the linker
Build(Box<build::Build>),
/// Send requests to Lambda functions running on the emulator
Invoke(invoke::Invoke),
/// Start a Lambda Runtime emulator to test and debug functions locally
Start(start::Start),
}
#[tokio::main]
async fn main() -> Result<()> {
let app = App::parse();
match app {
App::Lambda(lambda) => match *lambda {
Lambda::Build(mut b) => b.run(),
Lambda::Invoke(i) => i.run().await,
Lambda::Start(s) => s.run().await,
},
App::Zig(zig) => zig.execute().map_err(|e| miette!(e)),
}
}