Skip to main content

btrfs_cli/
property.rs

1use crate::{Format, Runnable};
2use anyhow::Result;
3use clap::Parser;
4
5mod get;
6mod list;
7mod set;
8
9use get::PropertyGetCommand;
10use list::PropertyListCommand;
11use set::PropertySetCommand;
12
13/// Object type for property operations
14#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
15pub enum PropertyObjectType {
16    Inode,
17    Subvol,
18    Filesystem,
19    Device,
20}
21
22/// Modify properties of filesystem objects.
23///
24/// Get, set, and list properties of filesystem objects including subvolumes,
25/// inodes, the filesystem itself, and devices. Properties control various
26/// aspects of filesystem behavior such as read-only status, compression,
27/// and labels. Most property operations require CAP_SYS_ADMIN or appropriate
28/// filesystem permissions.
29#[derive(Parser, Debug)]
30pub struct PropertyCommand {
31    #[clap(subcommand)]
32    pub subcommand: PropertySubcommand,
33}
34
35impl Runnable for PropertyCommand {
36    fn run(&self, format: Format, dry_run: bool) -> Result<()> {
37        match &self.subcommand {
38            PropertySubcommand::Get(cmd) => cmd.run(format, dry_run),
39            PropertySubcommand::Set(cmd) => cmd.run(format, dry_run),
40            PropertySubcommand::List(cmd) => cmd.run(format, dry_run),
41        }
42    }
43}
44
45#[derive(Parser, Debug)]
46pub enum PropertySubcommand {
47    Get(PropertyGetCommand),
48    Set(PropertySetCommand),
49    List(PropertyListCommand),
50}