/* * Copyright (c) 2026 MCorange. * All rights reserved. * * Unauthorized copying, modification, distribution, or use of this * software, in whole or in part, is prohibited without prior written * permission. */ use std::net::IpAddr; use clap::ArgGroup; #[derive(Debug, Clone, clap::Parser, Default)] #[command( author = env!("CARGO_PKG_AUTHORS"), version, after_help = concat!( "Made by: ", env!("CARGO_PKG_AUTHORS"), "\n", "All Rights Reserved" ) )] pub struct CliArgs { /// Configuration file path #[arg(long = "config", short = 'C', default_value = "./config.toml")] pub config_file: camino::Utf8PathBuf, /// Output more information in logs #[arg(long = "verbose", short = 'v', conflicts_with = "quiet")] pub verbose: bool, /// Output more information in logs #[arg(long = "quiet", short = 'q', conflicts_with = "verbose")] pub quiet: bool, #[command(subcommand)] pub command: CliCommand, } #[derive(Debug, Clone, clap::Subcommand, Default)] pub enum CliCommand { /// Run command once #[command( group( ArgGroup::new("devs") .args(["all", "devices"]) .required(true) ) )] Run { /// Run on ALL devices #[arg(long, short = 'a')] all: bool, /// Run on all specified devices #[arg(long, short = 'd')] devices: Vec, /// Command to run #[arg(long, short = 'c')] command: String, /// Output format #[arg(long, short = 'f')] format: OutputFormat, }, /// Run command continuosly #[command( group( ArgGroup::new("devs") .args(["all", "devices"]) .required(true) ) )] Monitor { /// Run on ALL devices #[arg(long, short = 'a')] all: bool, /// Run on all specified devices #[arg(long, short = 'd')] devices: Vec, /// Command to run #[arg(long, short = 'c')] command: String, /// Output format #[arg(long, short = 'f')] format: OutputFormat, /// Interval to run the commands at #[arg(long, short = 'i')] interval: f32, }, /// Manage devices Device { #[command(subcommand)] command: CliDeviceCommand, }, BesWifi { #[arg(long, short = 'i', value_parser = humantime::parse_duration, default_value="5m")] interval: std::time::Duration, }, #[default] #[clap(skip)] None, } #[derive(Debug, Clone, clap::Subcommand, Default)] pub enum CliDeviceCommand { /// List devices List, Add { /// Device name #[arg(short = 'n', long)] name: String, /// Device address, ipv4 or ipv6 #[arg(short = 'H', long)] host: IpAddr, /// Device Port (skip for default) #[arg(short = 'p', long)] port: Option, /// Username (skip for default) #[arg(short = 'U', long)] username: Option, /// Password (skip for default) #[arg(short = 'P', long)] password: Option, }, Remove { /// Name of the device #[arg(short, long)] name: String, }, #[default] #[clap(skip)] None, } #[derive(Clone, Debug, Default, clap::ValueEnum)] pub enum OutputFormat { #[default] Csv, Table, Json, }