mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-07 15:53:25 +02:00
fix(core): Fix async panic on blocking #19
Replaced internal threads with tokio spawn functions
This commit is contained in:
@@ -13,11 +13,11 @@ impl Cli {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn execute(self, args: &[&str]) -> eyre::Result<()> {
|
||||
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)?,
|
||||
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args).await?,
|
||||
_ => eyre::bail!("command missing"),
|
||||
}
|
||||
|
||||
|
@@ -17,12 +17,12 @@ impl GenerateCommand {
|
||||
clap::Command::new("generate").arg(Arg::new("output").long("output"))
|
||||
}
|
||||
|
||||
pub fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
|
||||
pub async fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
|
||||
let cfg = Config::default();
|
||||
let (conn, _proc) = Engine::new().start(&cfg)?;
|
||||
let (conn, _proc) = Engine::new().start(&cfg).await?;
|
||||
let session = Session::new();
|
||||
let req = session.start(&cfg, &conn)?;
|
||||
let schema = session.schema(req)?;
|
||||
let schema = session.schema(req).await?;
|
||||
let code = generate(
|
||||
schema.into_schema().schema.unwrap(),
|
||||
Arc::new(RustGenerator {}),
|
||||
|
@@ -3,14 +3,15 @@ use cli::Cli;
|
||||
pub mod cli;
|
||||
mod cli_generate;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
color_eyre::install().unwrap();
|
||||
|
||||
let args = std::env::args();
|
||||
let args = args.collect::<Vec<String>>();
|
||||
let args = args.iter().map(|s| s.as_str()).collect::<Vec<&str>>();
|
||||
|
||||
Cli::new()?.execute(args.as_slice())?;
|
||||
Cli::new()?.execute(args.as_slice()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user