dagger-rs/src/cli.rs
kjuulh 75bc17e57d fix(core): Fix async panic on blocking #19
Replaced internal threads with tokio spawn functions
2023-02-20 10:19:43 +01:00

27 lines
657 B
Rust

use crate::cli_generate;
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)
.subcommand(cli_generate::GenerateCommand::new_cmd()),
})
}
pub async fn execute(self, args: &[&str]) -> eyre::Result<()> {
let matches = self.cmd.get_matches_from(args);
match matches.subcommand() {
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args).await?,
_ => eyre::bail!("command missing"),
}
Ok(())
}
}