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