This commit is contained in:
2026-07-02 18:56:08 +03:00
parent 2752888e14
commit 16615d32c1
4 changed files with 146 additions and 17 deletions

View File

@@ -1,4 +1,6 @@
#[derive(Debug, Clone, Default, clap::Parser)]
use clap::ArgGroup;
#[derive(Debug, Clone, clap::Parser, Default)]
pub struct CliArgs {
/// Configuration file path
#[arg(long = "config", short = 'C', default_value = "./config.toml")]
@@ -7,4 +9,71 @@ pub struct CliArgs {
/// Output more information in logs
#[arg(long = "verbose", short = 'v')]
pub verbose: 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<String>,
/// Command to run
#[arg(long, short = 'c')]
command: String,
},
/// 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<String>,
/// Command to run
#[arg(long, short = 'c')]
command: String,
#[arg(long, short = 'i')]
/// Interval to run the commands at
interval: f32,
},
/// Manage devices
Device {
#[command(subcommand)]
command: CliDeviceCommand,
},
#[default]
#[clap(skip)]
None,
}
#[derive(Debug, Clone, clap::Subcommand, Default)]
pub enum CliDeviceCommand {
/// List devices
List,
#[default]
#[clap(skip)]
None,
}