MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / write_with_command

Function write_with_command

crates/opencode-tui/src/ui/clipboard.rs:128–154  ·  view source on GitHub ↗
(program: &str, args: &[&str], text: &str)

Source from the content-addressed store, hash-verified

126}
127
128fn write_with_command(program: &str, args: &[&str], text: &str) -> anyhow::Result<()> {
129 let mut child = Command::new(program)
130 .args(args)
131 .stdin(Stdio::piped())
132 .stdout(Stdio::null())
133 .stderr(Stdio::null())
134 .spawn()
135 .with_context(|| format!("failed to execute clipboard write command: {program}"))?;
136
137 if let Some(mut stdin) = child.stdin.take() {
138 stdin.write_all(text.as_bytes()).with_context(|| {
139 format!("failed to write text to clipboard command stdin: {program}")
140 })?;
141 }
142
143 let status = child
144 .wait()
145 .with_context(|| format!("failed waiting for clipboard command: {program}"))?;
146 if !status.success() {
147 anyhow::bail!(
148 "clipboard write command `{}` failed with status {}",
149 program,
150 status
151 );
152 }
153 Ok(())
154}
155
156fn read_raw_with_command(program: &str, args: &[&str]) -> anyhow::Result<Vec<u8>> {
157 let output = Command::new(program)

Callers 1

write_textMethod · 0.85

Calls 3

newFunction · 0.85
spawnMethod · 0.80
successMethod · 0.45

Tested by

no test coverage detected