Move subcommand branching into Options struct

This commit is contained in:
Lucien Greathouse
2021-06-08 16:53:03 -04:00
parent 1413f8c0b6
commit 158dac5e1c
2 changed files with 16 additions and 16 deletions

View File

@@ -41,6 +41,20 @@ pub struct Options {
pub subcommand: Subcommand,
}
impl Options {
pub fn run(self) -> anyhow::Result<()> {
match self.subcommand {
Subcommand::Init(subcommand) => subcommand.run(),
Subcommand::Serve(serve_options) => serve(self.global, serve_options),
Subcommand::Build(subcommand) => subcommand.run(),
Subcommand::Upload(upload_options) => upload(upload_options),
Subcommand::FmtProject(subcommand) => subcommand.run(),
Subcommand::Doc(subcommand) => subcommand.run(),
Subcommand::Plugin(subcommand) => subcommand.run(),
}
}
}
#[derive(Debug, StructOpt)]
pub struct GlobalOptions {
/// Sets verbosity level. Can be specified multiple times.