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
16use commit_stats::FilesystemCommitStatsCommand;
17use defrag::FilesystemDefragCommand;
18use df::FilesystemDfCommand;
19use du::FilesystemDuCommand;
20use label::FilesystemLabelCommand;
21use mkswapfile::FilesystemMkswapfileCommand;
22use resize::FilesystemResizeCommand;
23use show::FilesystemShowCommand;
24use sync::FilesystemSyncCommand;
25use usage::FilesystemUsageCommand;
26
27#[derive(Parser, Debug)]
34pub struct FilesystemCommand {
35 #[clap(subcommand)]
36 pub subcommand: FilesystemSubcommand,
37}
38
39impl Runnable for FilesystemCommand {
40 fn run(&self, format: Format, dry_run: bool) -> Result<()> {
41 match &self.subcommand {
42 FilesystemSubcommand::Df(cmd) => cmd.run(format, dry_run),
43 FilesystemSubcommand::Du(cmd) => cmd.run(format, dry_run),
44 FilesystemSubcommand::Show(cmd) => cmd.run(format, dry_run),
45 FilesystemSubcommand::Sync(cmd) => cmd.run(format, dry_run),
46 FilesystemSubcommand::Defragment(cmd) => cmd.run(format, dry_run),
47 FilesystemSubcommand::Resize(cmd) => cmd.run(format, dry_run),
48 FilesystemSubcommand::Label(cmd) => cmd.run(format, dry_run),
49 FilesystemSubcommand::Usage(cmd) => cmd.run(format, dry_run),
50 FilesystemSubcommand::Mkswapfile(cmd) => cmd.run(format, dry_run),
51 FilesystemSubcommand::CommitStats(cmd) => cmd.run(format, dry_run),
52 }
53 }
54}
55
56#[derive(Parser, Debug)]
57pub enum FilesystemSubcommand {
58 Df(FilesystemDfCommand),
59 Du(FilesystemDuCommand),
60 Show(FilesystemShowCommand),
61 Sync(FilesystemSyncCommand),
62 #[clap(alias = "defrag")]
63 Defragment(FilesystemDefragCommand),
64 Resize(FilesystemResizeCommand),
65 Label(FilesystemLabelCommand),
66 Usage(FilesystemUsageCommand),
67 Mkswapfile(FilesystemMkswapfileCommand),
68 CommitStats(FilesystemCommitStatsCommand),
69}
70
71#[derive(Args, Debug)]
77pub struct UnitMode {
78 #[clap(long, overrides_with_all = ["human_readable", "iec", "si", "kbytes", "mbytes", "gbytes", "tbytes"])]
80 pub raw: bool,
81
82 #[clap(long, overrides_with_all = ["raw", "iec", "si", "kbytes", "mbytes", "gbytes", "tbytes"])]
84 pub human_readable: bool,
85
86 #[clap(long, overrides_with_all = ["raw", "human_readable", "si", "kbytes", "mbytes", "gbytes", "tbytes"])]
88 pub iec: bool,
89
90 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "kbytes", "mbytes", "gbytes", "tbytes"])]
92 pub si: bool,
93
94 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "mbytes", "gbytes", "tbytes"])]
96 pub kbytes: bool,
97
98 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "kbytes", "gbytes", "tbytes"])]
100 pub mbytes: bool,
101
102 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "kbytes", "mbytes", "tbytes"])]
104 pub gbytes: bool,
105
106 #[clap(long, overrides_with_all = ["raw", "human_readable", "iec", "si", "kbytes", "mbytes", "gbytes"])]
108 pub tbytes: bool,
109}