feat: with cuddle x render
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-01-28 21:06:16 +01:00
parent c0ae03376b
commit 8788f78f81
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,42 @@
pub struct CuddleX {
command: String,
args: Vec<String>,
}
impl CuddleX {
pub fn command(command: impl Into<String>) -> Self {
Self {
command: command.into(),
args: Vec::new(),
}
}
pub fn arg(&mut self, arg: impl Into<String>) -> &mut Self {
self.args.push(arg.into());
self
}
pub async fn run(&mut self) -> eyre::Result<(String, String, i32)> {
let mut cmd = tokio::process::Command::new("cuddle");
let cmd = cmd.arg("x").arg(&self.command).args(&self.args);
let output = cmd.output().await?;
Ok((
std::str::from_utf8(&output.stdout)?.to_string(),
std::str::from_utf8(&output.stderr)?.to_string(),
output.status.code().unwrap_or(0),
))
}
}
pub mod well_known {
use super::CuddleX;
pub async fn render() -> eyre::Result<()> {
CuddleX::command("render").run().await?;
Ok(())
}
}

View File

@ -9,4 +9,5 @@ pub mod rust_service;
pub mod cuddle_file; pub mod cuddle_file;
pub mod cuddle_please; pub mod cuddle_please;
pub mod cuddle_releaser; pub mod cuddle_releaser;
pub mod cuddle_x;
pub mod dagger_middleware; pub mod dagger_middleware;