1use crate::{Format, Runnable};
2use anyhow::Result;
3use clap::{Args, Parser};
4
5mod commit_stats;
6mod defrag;
7mod df;
8mod du;
9mod label;
10mod mkswapfile;
11mod resize;
12mod show;
13mod sync;
14mod usage;
15
16pub use self::{
17 commit_stats::*, defrag::*, df::*, du::*, label::*, mkswapfile::*,
18 resize::*, show::*, sync::*, usage::*,
19};
20
21#[derive(Parser, Debug)]
28pub struct FilesystemCommand {
29 #[clap(subcommand)]
30 pub subcommand: FilesystemSubcommand,
31}
32
33impl Runnable for FilesystemCommand {
34 fn run(&self, format: Format, dry_run: bool) -> Result<()> {
35 match &self.subcommand {
36 FilesystemSubcommand::Df(cmd) => cmd.run(format, dry_run),
37 FilesystemSubcommand::Du(cmd) => cmd.run(format, dry_run),
38 FilesystemSubcommand::Show(cmd) => cmd.run(format, dry_run),
39 FilesystemSubcommand::Sync(cmd) => cmd.run(format, dry_run),
40 FilesystemSubcommand::Defragment(cmd) => cmd.run(format, dry_run),
41 FilesystemSubcommand::Resize(cmd) => cmd.run(format, dry_run),
42 FilesystemSubcommand::Label(cmd) => cmd.run(format, dry_run),
43 FilesystemSubcommand::Usage(cmd) => cmd.run(format, dry_run),
44 FilesystemSubcommand::Mkswapfile(cmd) => cmd.run(format, dry_run),
45 FilesystemSubcommand::CommitStats(cmd) => cmd.run(format, dry_run),
46 }
47 }
48}
49
50#[derive(Parser, Debug)]
51pub enum FilesystemSubcommand {
52 Df(FilesystemDfCommand),
53 Du(FilesystemDuCommand),
54 Show(FilesystemShowCommand),
55 Sync(FilesystemSyncCommand),
56 #[clap(alias = "defrag")]
57 Defragment(FilesystemDefragCommand),
58 Resize(FilesystemResizeCommand),
59 Label(FilesystemLabelCommand),
60 Usage(FilesystemUsageCommand),
61 Mkswapfile(FilesystemMkswapfileCommand),
62 CommitStats(FilesystemCommitStatsCommand),
63}
64
65#[derive(Args, Debug)]
71pub struct UnitMode {
72 #[clap(long, overrides_with_all = ["human_readable", "iec", "si", "kbytes", "mbytes", "gbytes", "tbytes"])]
74 pub raw: bool,
75
76 #[clap(long, overrides_with_all = ["raw", "iec", "si", "kbytes", "mbytes", "gbytes", "tbytes"])]
78 pub human_readable: bool,
79
80 #[clap(long, overrides_with_all = ["raw", "human_readable", "si", "kbytes", "mbytes", "gbytes", "tbytes"])]
82 pub iec: bool,
83
84 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "kbytes", "mbytes", "gbytes", "tbytes"])]
86 pub si: bool,
87
88 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "mbytes", "gbytes", "tbytes"])]
90 pub kbytes: bool,
91
92 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "kbytes", "gbytes", "tbytes"])]
94 pub mbytes: bool,
95
96 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "kbytes", "mbytes", "tbytes"])]
98 pub gbytes: bool,
99
100 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "kbytes", "mbytes", "gbytes"])]
102 pub tbytes: bool,
103}