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