mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 10:30:41 +08:00
We split out all non-radicle terminal functionality so that it can be accessed by `radicle-node` without importing `radicle-cli`.
20 lines
412 B
Rust
20 lines
412 B
Rust
use std::io::Write;
|
|
use std::process::{Command, Stdio};
|
|
|
|
pub fn bat<S: AsRef<std::ffi::OsStr>>(
|
|
args: impl IntoIterator<Item = S>,
|
|
stdin: &str,
|
|
) -> anyhow::Result<()> {
|
|
let mut child = Command::new("bat")
|
|
.stdin(Stdio::piped())
|
|
.args(args)
|
|
.spawn()?;
|
|
|
|
let writer = child.stdin.as_mut().unwrap();
|
|
writer.write_all(stdin.as_bytes())?;
|
|
|
|
child.wait()?;
|
|
|
|
Ok(())
|
|
}
|