wireman_config/
cli.rs

1use crate::{install::install, setup::setup};
2use clap::{Parser, Subcommand};
3
4#[derive(Debug, Parser)]
5#[clap(name = "wireman", version)]
6pub struct Args {
7    #[clap(subcommand)]
8    pub command: Option<Command>,
9
10    /// Optional path to the configuration file
11    #[arg(short, long)]
12    pub config: Option<String>,
13
14    /// Use local protobuf files
15    #[arg(short, long)]
16    pub local_protos: bool,
17}
18
19#[derive(Debug, Subcommand)]
20pub enum Command {
21    /// Runs a health check and prompts configuration details.
22    Check,
23    /// Setup wireman and create a default configuration file.
24    #[command(aliases = ["setup", "install"])]
25    Init,
26}
27
28#[must_use]
29pub fn parse() -> Args {
30    let args = Args::parse();
31    match args.command {
32        Some(Command::Check) => {
33            let _ = setup(true, &args);
34        }
35        Some(Command::Init) => {
36            install();
37        }
38        None => {}
39    }
40    args
41}