Many fixes for the clipboard and others

- Reverse connections must be maintained to ensure messages are
  processed in order. (Whoops!)
- The clipboard context must remain live in order for the data to
  remain available for applications, at least on X11. (And it couldn't
  hurt elsewhere, either, I guess.)
- Print out the server version at startup time, so we can be sure what
  we're talking to.
- Print out the full details of the error when something goes wrong
  with `browse` or `clip`.
This commit is contained in:
John Doty 2024-08-08 10:03:47 -07:00
parent a3fa032500
commit 2a582e25a8
7 changed files with 110 additions and 57 deletions

View file

@ -1,10 +1,6 @@
// TODO: An actual proper command line parsing
use indoc::indoc;
const VERSION: &str = env!("CARGO_PKG_VERSION");
const REV: &str = env!("REPO_REV");
const DIRTY: &str = env!("REPO_DIRTY");
fn usage() {
println!(indoc! {"
usage: fwd [options] (<server> | browse <url> | clip [<file>])
@ -121,7 +117,7 @@ fn parse_args(args: Vec<String>) -> Args {
async fn browse_url(url: &str) {
if let Err(e) = fwd::browse_url(url).await {
eprintln!("Unable to open {url}");
eprintln!("{}", e);
eprintln!("{:#}", e);
std::process::exit(1);
}
}
@ -129,7 +125,7 @@ async fn browse_url(url: &str) {
async fn clip_file(file: String) {
if let Err(e) = fwd::clip_file(&file).await {
eprintln!("Unable to copy to the clipboard");
eprintln!("{}", e);
eprintln!("{:#}", e);
std::process::exit(1);
}
}
@ -141,7 +137,7 @@ async fn main() {
usage();
}
Args::Version => {
println!("fwd {VERSION} (rev {REV}{DIRTY})");
println!("fwd {} (rev {}{})", fwd::VERSION, fwd::REV, fwd::DIRTY);
}
Args::Server => {
fwd::run_server().await;