Skip to main content

btrfs_cli/
qgroup.rs

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/// Manage quota groups.
22///
23/// Create, destroy, and configure quota groups to enforce storage limits and
24/// track usage for subvolumes and hierarchies of subvolumes. Quota groups
25/// provide flexible quota management that can be applied at different levels
26/// in the subvolume hierarchy. Most operations require CAP_SYS_ADMIN.
27#[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}