Skip to main content

btrfs_cli/
replace.rs

1use crate::{CommandGroup, Runnable};
2use clap::Parser;
3
4mod cancel;
5mod start;
6mod status;
7
8pub use self::{cancel::*, start::*, status::*};
9
10/// Replace a device in the filesystem.
11///
12/// Replace a device with another device or a spare. During replacement,
13/// data is read from the old device and written to the new one. The replace
14/// operation can be monitored and cancelled. Requires CAP_SYS_ADMIN.
15#[derive(Parser, Debug)]
16#[allow(clippy::doc_markdown)]
17#[clap(arg_required_else_help = true)]
18pub struct ReplaceCommand {
19    #[clap(subcommand)]
20    pub subcommand: ReplaceSubcommand,
21}
22
23impl CommandGroup for ReplaceCommand {
24    fn leaf(&self) -> &dyn Runnable {
25        match &self.subcommand {
26            ReplaceSubcommand::Start(cmd) => cmd,
27            ReplaceSubcommand::Status(cmd) => cmd,
28            ReplaceSubcommand::Cancel(cmd) => cmd,
29        }
30    }
31}
32
33#[derive(Parser, Debug)]
34pub enum ReplaceSubcommand {
35    Start(ReplaceStartCommand),
36    Status(ReplaceStatusCommand),
37    Cancel(ReplaceCancelCommand),
38}