vertigo_cli/
main.rs

1pub mod build;
2mod commons;
3pub mod new;
4pub mod serve;
5pub mod watch;
6
7use clap::{Parser, Subcommand};
8
9pub use build::BuildOpts;
10pub use commons::models::CommonOpts;
11pub use new::NewOpts;
12pub use serve::ServeOpts;
13pub use watch::WatchOpts;
14
15#[derive(Parser)]
16#[command(author, version, about, long_about = None)]
17#[command(propagate_version = true)]
18struct Cli {
19    #[command(subcommand)]
20    command: Command,
21}
22
23#[derive(Subcommand)]
24enum Command {
25    New(NewOpts),
26    Build(BuildOpts),
27    Serve(ServeOpts),
28    Watch(WatchOpts),
29}
30
31#[tokio::main]
32pub async fn main() -> Result<(), i32> {
33    env_logger::Builder::new()
34        .filter(None, log::LevelFilter::Info)
35        .filter(Some("cargo::core::compiler"), log::LevelFilter::Warn)
36        .filter(Some("cranelift_codegen::context"), log::LevelFilter::Warn)
37        .init();
38
39    let cli = Cli::parse();
40    match cli.command {
41        Command::Build(opts) => build::run(opts),
42        Command::New(opts) => new::run(opts),
43        Command::Serve(opts) => serve::run(opts, None).await,
44        Command::Watch(opts) => watch::run(opts).await,
45    }
46}