1use crate::command::NewCommand;
2use camino::Utf8PathBuf;
3use clap::{Parser, Subcommand, ValueEnum};
4
5#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
6pub enum Log {
7 Wasm,
9 Server,
11}
12
13#[derive(Debug, Clone, Parser, PartialEq, Default)]
14pub struct Opts {
15 #[arg(short, long)]
17 pub release: bool,
18
19 #[arg(long)]
21 pub hot_reload: bool,
22
23 #[arg(short, long)]
25 pub project: Option<String>,
26
27 #[arg(long)]
29 pub features: Vec<String>,
30
31 #[arg(long)]
33 pub lib_features: Vec<String>,
34
35 #[arg(long)]
37 pub bin_features: Vec<String>,
38
39 #[arg(short, action = clap::ArgAction::Count)]
41 pub verbose: u8,
42}
43
44#[derive(Debug, Parser)]
45#[clap(version)]
46pub struct Cli {
47 #[arg(long)]
49 pub manifest_path: Option<Utf8PathBuf>,
50
51 #[arg(long)]
53 pub log: Vec<Log>,
54
55 #[command(subcommand)]
56 pub command: Commands,
57}
58
59impl Cli {
60 pub fn opts(&self) -> Option<Opts> {
61 use Commands::{Build, EndToEnd, New, Serve, Test, Watch};
62 match &self.command {
63 New(_) => None,
64 Build(opts) | Serve(opts) | Test(opts) | EndToEnd(opts) | Watch(opts) => Some(opts.clone()),
65 }
66 }
67}
68
69#[derive(Debug, Subcommand, PartialEq)]
70pub enum Commands {
71 Build(Opts),
73 Test(Opts),
75 EndToEnd(Opts),
77 Serve(Opts),
79 Watch(Opts),
81 New(NewCommand),
83}