1use crate::{install::install, setup::setup};
2use clap::{CommandFactory, FromArgMatches};
3use clap::{Parser, Subcommand};
4
5#[derive(Debug, Parser)]
6#[clap(name = "wireman")]
7pub struct Args {
8 #[clap(subcommand)]
9 pub command: Option<Command>,
10
11 #[arg(short, long)]
13 pub config: Option<String>,
14
15 #[arg(short, long)]
17 pub local_protos: bool,
18}
19
20#[derive(Debug, Subcommand)]
21pub enum Command {
22 Check,
24 #[command(aliases = ["setup", "install"])]
26 Init,
27}
28
29#[must_use]
30pub fn parse(version: &'static str) -> Args {
31 let matches = Args::command().version(version).get_matches();
32 let args = Args::from_arg_matches(&matches).unwrap();
33 match args.command {
34 Some(Command::Check) => {
35 let _ = setup(true, &args);
36 }
37 Some(Command::Init) => {
38 install();
39 }
40 None => {}
41 }
42 args
43}