1use crate::{Format, Runnable};
2use anyhow::Result;
3use clap::Parser;
4
5mod dump_super;
6mod dump_tree;
7mod inode_resolve;
8mod list_chunks;
9mod logical_resolve;
10mod map_swapfile;
11mod min_dev_size;
12mod print_super;
13mod print_tree;
14mod rootid;
15mod subvolid_resolve;
16mod tree_stats;
17
18pub use self::{
19 dump_super::*, dump_tree::*, inode_resolve::*, list_chunks::*,
20 logical_resolve::*, map_swapfile::*, min_dev_size::*, rootid::*,
21 subvolid_resolve::*, tree_stats::*,
22};
23
24#[derive(Parser, Debug)]
32pub struct InspectCommand {
33 #[clap(subcommand)]
34 pub subcommand: InspectSubcommand,
35}
36
37#[derive(Parser, Debug)]
38pub enum InspectSubcommand {
39 Rootid(RootidCommand),
40 InodeResolve(InodeResolveCommand),
41 LogicalResolve(LogicalResolveCommand),
42 SubvolidResolve(SubvolidResolveCommand),
43 MapSwapfile(MapSwapfileCommand),
44 MinDevSize(MinDevSizeCommand),
45 DumpTree(DumpTreeCommand),
46 DumpSuper(DumpSuperCommand),
47 TreeStats(TreeStatsCommand),
48 ListChunks(ListChunksCommand),
49}
50
51impl Runnable for InspectCommand {
52 fn run(&self, format: Format, dry_run: bool) -> Result<()> {
53 match &self.subcommand {
54 InspectSubcommand::Rootid(cmd) => cmd.run(format, dry_run),
55 InspectSubcommand::InodeResolve(cmd) => cmd.run(format, dry_run),
56 InspectSubcommand::LogicalResolve(cmd) => cmd.run(format, dry_run),
57 InspectSubcommand::SubvolidResolve(cmd) => cmd.run(format, dry_run),
58 InspectSubcommand::MapSwapfile(cmd) => cmd.run(format, dry_run),
59 InspectSubcommand::MinDevSize(cmd) => cmd.run(format, dry_run),
60 InspectSubcommand::DumpTree(cmd) => cmd.run(format, dry_run),
61 InspectSubcommand::DumpSuper(cmd) => cmd.run(format, dry_run),
62 InspectSubcommand::TreeStats(cmd) => cmd.run(format, dry_run),
63 InspectSubcommand::ListChunks(cmd) => cmd.run(format, dry_run),
64 }
65 }
66}