Skip to main content

life_cli/
lib.rs

1//! Life CLI — library entrypoint for embedding in life-os.
2
3pub mod cli;
4pub mod cost;
5pub mod deploy;
6pub mod init;
7pub mod logs;
8pub mod relay;
9pub mod scale;
10pub mod setup;
11pub mod status;
12pub mod template;
13
14use anyhow::Result;
15use clap::Parser;
16
17/// Run the Life CLI with the given args (or from std::env).
18pub async fn run() -> Result<()> {
19    tracing_subscriber::fmt()
20        .with_env_filter(
21            tracing_subscriber::EnvFilter::from_default_env().add_directive("life=info".parse()?),
22        )
23        .init();
24
25    let cli = cli::Cli::parse();
26
27    match cli.command {
28        None => {
29            setup::print_quick_help();
30            Ok(())
31        }
32        Some(cmd) => match cmd {
33            cli::Command::Init => init::run(),
34            cli::Command::Setup => setup::run().await,
35            cli::Command::Deploy(args) => deploy::run(args).await,
36            cli::Command::Status(args) => status::run(args).await,
37            cli::Command::List(args) => deploy::list(args).await,
38            cli::Command::Destroy(args) => deploy::destroy(args).await,
39            cli::Command::Templates(args) => template::run(args),
40            cli::Command::Cost(args) => cost::run(args).await,
41            cli::Command::Logs(args) => logs::run(args).await,
42            cli::Command::Scale(args) => scale::run(args).await,
43            cli::Command::Relay { command } => relay::run(command).await,
44        },
45    }
46}