1use anyhow::Result;
2use clap::Parser;
3mod commands;
4mod template;
5mod utils;
6
7#[derive(Debug, Parser)]
8#[clap(version)]
9pub struct Opts {
10 #[clap(subcommand)]
11 pub command: Command,
12}
13
14#[derive(Debug, Parser)]
15pub enum Command {
16 Build {
18 name: String,
20 },
21 Serve {
23 name: String,
25 #[clap(short, long)]
27 address: Option<String>,
28 #[clap(short, long)]
30 port: Option<u16>,
31 #[clap(long)]
33 protocol: Option<String>,
34 },
35 Test,
37 Deploy {
39 name: String,
41 project: String,
43 },
44 Clean,
46 Init {
48 name: String,
50 #[clap(short, long)]
52 dry_run: bool,
53 },
54 New {
56 name: String,
57 #[clap(short, long)]
59 dry_run: bool,
60 },
61}
62
63fn process_command(opts: Opts) -> Result<()> {
64 match &opts.command {
65 Command::Build { name } => {
66 commands::build::run(name);
67 Ok(())
68 }
69 Command::Serve {
70 name,
71 address,
72 port,
73 protocol,
74 } => {
75 commands::serve::run(name, address.as_deref(), port.as_ref(), protocol.as_deref());
76 Ok(())
77 }
78 Command::Test => {
79 commands::test::run();
80 Ok(())
81 }
82 Command::Clean => {
83 commands::clean::run();
84 Ok(())
85 }
86 Command::Init { name, dry_run } => {
87 commands::init::run(name, *dry_run);
88 Ok(())
89 }
90 Command::New { name, dry_run } => {
91 commands::new::run(name, *dry_run);
92 Ok(())
93 }
94 Command::Deploy { name, project } => {
95 commands::deploy::run(name, project);
96 Ok(())
97 }
98 }
99}
100
101pub fn entry(opts: Opts) -> Result<()> {
102 process_command(opts)
103}