1use crate::{Format, Runnable};
2use anyhow::Result;
3use clap::Parser;
4
5mod add;
6mod ready;
7mod remove;
8mod scan;
9mod stats;
10mod usage;
11
12pub use self::{add::*, ready::*, remove::*, scan::*, stats::*, usage::*};
13
14#[derive(Parser, Debug)]
20pub struct DeviceCommand {
21 #[clap(subcommand)]
22 pub subcommand: DeviceSubcommand,
23}
24
25impl Runnable for DeviceCommand {
26 fn run(&self, format: Format, dry_run: bool) -> Result<()> {
27 match &self.subcommand {
28 DeviceSubcommand::Add(cmd) => cmd.run(format, dry_run),
29 DeviceSubcommand::Remove(cmd) | DeviceSubcommand::Delete(cmd) => {
30 cmd.run(format, dry_run)
31 }
32 DeviceSubcommand::Stats(cmd) => cmd.run(format, dry_run),
33 DeviceSubcommand::Scan(cmd) => cmd.run(format, dry_run),
34 DeviceSubcommand::Ready(cmd) => cmd.run(format, dry_run),
35 DeviceSubcommand::Usage(cmd) => cmd.run(format, dry_run),
36 }
37 }
38}
39
40#[derive(Parser, Debug)]
41pub enum DeviceSubcommand {
42 Add(DeviceAddCommand),
43 Remove(DeviceRemoveCommand),
44 #[clap(alias = "del")]
45 Delete(DeviceRemoveCommand),
46 Stats(DeviceStatsCommand),
47 Scan(DeviceScanCommand),
48 Ready(DeviceReadyCommand),
49 Usage(DeviceUsageCommand),
50}