kjuulh
5875c96aa8
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
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<()> {
|
|
let (stdout, stderr, _) = CuddleX::command("render").run().await?;
|
|
|
|
for line in stdout.lines() {
|
|
tracing::trace!("render: {}", line);
|
|
}
|
|
|
|
for line in stderr.lines() {
|
|
tracing::trace!("render: {}", line);
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|