1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
mod check;
mod format;
mod rust;

#[derive(structopt::StructOpt)]
pub struct App {
    #[structopt(flatten)]
    app_options: AppOptions,

    #[structopt(subcommand)]
    command: Command,
}

#[derive(structopt::StructOpt)]
pub enum Command {
    Rust(rust::Command),
    Format(format::Command),
    Check(check::Command),
}

#[derive(Default, structopt::StructOpt)]
pub struct AppOptions {}

impl App {
    pub fn run(self) -> anyhow::Result<()> {
        match self.command {
            Command::Rust(command) => command.run(self.app_options)?,
            Command::Format(command) => command.run(self.app_options)?,
            Command::Check(command) => command.run(self.app_options)?,
        }
        Ok(())
    }
}