Repository navigation
feat(share): add --copy option to copy ticket to clipboard - #7
Conversation
There was a problem hiding this comment.
Thanks for this, the structure is good and the docs are in the right places. One blocking bug and a few small things before it can go in:
1. beemr share --copy hangs forever on Linux with xclip, xsel and wl-copy (blocking)
These tools fork a background process that keeps owning the clipboard, and that process inherits our stderr pipe. wait_with_output() reads stderr until end-of-file, which only comes when that background process exits, usually when something else is copied. Since copy_to_clipboard runs before the DHT record is published, the share never starts. I reproduced it in an Alpine container with Xvfb: reading xclip's stderr through a pipe was still blocked after 5 minutes.
The fix is to not capture output, and wait only for the process we started:
let mut child = Command::new(cmd)
.args(args)
.stdin(Stdio::piped())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.map_err(|e| e.to_string())?;
if let Some(mut stdin) = child.stdin.take() {
stdin.write_all(text.as_bytes()).map_err(|e| e.to_string())?;
} // stdin is dropped here, so the tool sees end-of-file
let status = child.wait().map_err(|e| e.to_string())?;
if status.success() { Ok(()) } else { Err(format!("exited with {status}")) }With that change both xclip and xsel return immediately and the clipboard holds the command.
2. cargo fmt --check fails. Please run cargo fmt; CI checks it.
3. Say when it worked. Please print a confirmation on success, e.g. ✓ Copied the command to the clipboard. For failure, a shorter hint is friendlier than the joined error list, e.g. ✗ Couldn't copy to the clipboard (install wl-clipboard, xclip or xsel) on Linux.
4. Add --copy to the usage text under "Share options:" at the top of src/main.rs, so beemr help lists it.
Happy to merge once these are in.
eeb3baa to
3713000
Compare
|
Hi @osmanahmadxai, thanks for the helpful feedback and reproduction details! I have addressed all review items:
|
Closes #3
Summary of Changes
--copyflag tobeemr shareto place thebeemr get <ticket>command directly on the clipboard.src/share.rs:clip.exeon Windows.pbcopyon macOS.wl-copy, falling back toxclip(-selection clipboard), thenxsel(--clipboard --input) on Linux.--copyto the option parsing insrc/main.rs.--copyin the README options table and manpage indocs/beemr.1.