1#![doc = include_str!("../README.md")]
2
3use clap::{Parser, Subcommand};
4use std::process::exit;
5
6pub mod build;
7mod commons;
8pub mod new;
9pub mod serve;
10pub mod watch;
11
12pub use build::BuildOpts;
13pub use commons::models::CommonOpts;
14pub use new::NewOpts;
15pub use serve::ServeOpts;
16pub use watch::WatchOpts;
17
18pub use serve::vertigo_install;
20
21use commons::logging::setup_logging;
22
23#[derive(Parser)]
24#[command(author, version, about, long_about = None)]
25#[command(propagate_version = true)]
26struct Cli {
27 #[command(subcommand)]
28 command: Command,
29}
30
31#[derive(Subcommand)]
32enum Command {
33 New(NewOpts),
34 Build(BuildOpts),
35 Serve(ServeOpts),
36 Watch(WatchOpts),
37}
38
39#[tokio::main]
40pub async fn main() -> Result<(), i32> {
41 let cli = Cli::parse();
42
43 setup_logging(&cli.command);
44
45 let ret = match cli.command {
46 Command::Build(opts) => build::run(opts),
47 Command::New(opts) => new::run(opts),
48 Command::Serve(opts) => serve::run(opts, None).await,
49 Command::Watch(opts) => watch::run(opts).await,
50 };
51
52 if let Err(err) = ret {
54 exit(err as i32);
55 }
56
57 Ok(())
58}