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