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