2023-01-28 20:21:19 +01:00
|
|
|
use crate::cli_generate;
|
|
|
|
|
2023-01-27 08:31:09 +01:00
|
|
|
pub struct Cli {
|
|
|
|
cmd: clap::Command,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Cli {
|
|
|
|
pub fn new() -> eyre::Result<Self> {
|
|
|
|
Ok(Self {
|
|
|
|
cmd: clap::Command::new("dagger-rust")
|
|
|
|
.subcommand_required(true)
|
2023-01-28 20:21:19 +01:00
|
|
|
.subcommand(cli_generate::GenerateCommand::new_cmd()),
|
2023-01-27 08:31:09 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn execute(self, args: &[&str]) -> eyre::Result<()> {
|
|
|
|
let matches = self.cmd.get_matches_from(args);
|
|
|
|
|
|
|
|
match matches.subcommand() {
|
2023-01-28 20:21:19 +01:00
|
|
|
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args)?,
|
2023-01-27 08:31:09 +01:00
|
|
|
_ => eyre::bail!("command missing"),
|
|
|
|
}
|
2023-01-28 20:21:19 +01:00
|
|
|
|
|
|
|
Ok(())
|
2023-01-27 08:31:09 +01:00
|
|
|
}
|
|
|
|
}
|