1use crate::{Format, Runnable};
2use anyhow::Result;
3use clap::Parser;
4
5mod assign;
6mod clear_stale;
7mod create;
8mod destroy;
9mod limit;
10mod remove;
11mod show;
12
13use assign::QgroupAssignCommand;
14use clear_stale::QgroupClearStaleCommand;
15use create::QgroupCreateCommand;
16use destroy::QgroupDestroyCommand;
17use limit::QgroupLimitCommand;
18use remove::QgroupRemoveCommand;
19use show::QgroupShowCommand;
20
21#[derive(Parser, Debug)]
28pub struct QgroupCommand {
29 #[clap(subcommand)]
30 pub subcommand: QgroupSubcommand,
31}
32
33impl Runnable for QgroupCommand {
34 fn run(&self, format: Format, dry_run: bool) -> Result<()> {
35 match &self.subcommand {
36 QgroupSubcommand::Assign(cmd) => cmd.run(format, dry_run),
37 QgroupSubcommand::Remove(cmd) => cmd.run(format, dry_run),
38 QgroupSubcommand::Create(cmd) => cmd.run(format, dry_run),
39 QgroupSubcommand::Destroy(cmd) => cmd.run(format, dry_run),
40 QgroupSubcommand::Show(cmd) => cmd.run(format, dry_run),
41 QgroupSubcommand::Limit(cmd) => cmd.run(format, dry_run),
42 QgroupSubcommand::ClearStale(cmd) => cmd.run(format, dry_run),
43 }
44 }
45}
46
47#[derive(Parser, Debug)]
48pub enum QgroupSubcommand {
49 Assign(QgroupAssignCommand),
50 Remove(QgroupRemoveCommand),
51 Create(QgroupCreateCommand),
52 Destroy(QgroupDestroyCommand),
53 Show(QgroupShowCommand),
54 Limit(QgroupLimitCommand),
55 #[command(name = "clear-stale")]
56 ClearStale(QgroupClearStaleCommand),
57}