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) => cmd.run(format, dry_run),
30 DeviceSubcommand::Delete(cmd) => cmd.run(format, dry_run),
31 DeviceSubcommand::Stats(cmd) => cmd.run(format, dry_run),
32 DeviceSubcommand::Scan(cmd) => cmd.run(format, dry_run),
33 DeviceSubcommand::Ready(cmd) => cmd.run(format, dry_run),
34 DeviceSubcommand::Usage(cmd) => cmd.run(format, dry_run),
35 }
36 }
37}
38
39#[derive(Parser, Debug)]
40pub enum DeviceSubcommand {
41 Add(DeviceAddCommand),
42 Remove(DeviceRemoveCommand),
43 #[clap(alias = "del")]
44 Delete(DeviceRemoveCommand),
45 Stats(DeviceStatsCommand),
46 Scan(DeviceScanCommand),
47 Ready(DeviceReadyCommand),
48 Usage(DeviceUsageCommand),
49}