mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-13 06:23:47 +00:00
multicall: remove program name prefixes from log and error messages
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a6964f65a0f1e473a50abfa985365ad8f1fa1
This commit is contained in:
parent
6496d3963d
commit
78fa23a764
2 changed files with 17 additions and 23 deletions
|
|
@ -130,7 +130,7 @@ fn report_error<T>(
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)] // whatever
|
#[allow(clippy::too_many_lines)] // whatever
|
||||||
fn main() {
|
fn main() {
|
||||||
// Multicall dispatch: stash-copy, stash-paste, wl-copy, wl-paste
|
// Multicall dispatch: stash-copy, stash-paste, wl-copy, wl-paste
|
||||||
if crate::multicall::multicall_dispatch() {
|
if crate::multicall::multicall_dispatch() {
|
||||||
// If handled, exit immediately
|
// If handled, exit immediately
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
|
|
|
||||||
|
|
@ -92,23 +92,23 @@ fn multicall_stash_copy() {
|
||||||
if args.check_primary {
|
if args.check_primary {
|
||||||
match is_primary_selection_supported() {
|
match is_primary_selection_supported() {
|
||||||
Ok(true) => {
|
Ok(true) => {
|
||||||
log::info!("Primary selection is supported.");
|
log::info!("primary selection is supported.");
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
},
|
},
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
log::info!("Primary selection is NOT supported.");
|
log::info!("primary selection is NOT supported.");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
},
|
},
|
||||||
Err(PrimarySelectionCheckError::NoSeats) => {
|
Err(PrimarySelectionCheckError::NoSeats) => {
|
||||||
log::error!("Could not determine: no seats available.");
|
log::error!("could not determine: no seats available.");
|
||||||
std::process::exit(2);
|
std::process::exit(2);
|
||||||
},
|
},
|
||||||
Err(PrimarySelectionCheckError::MissingProtocol) => {
|
Err(PrimarySelectionCheckError::MissingProtocol) => {
|
||||||
log::error!("Data-control protocol not supported by compositor.");
|
log::error!("data-control protocol not supported by compositor.");
|
||||||
std::process::exit(3);
|
std::process::exit(3);
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Error checking primary selection support: {e}");
|
log::error!("error checking primary selection support: {e}");
|
||||||
std::process::exit(4);
|
std::process::exit(4);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -135,7 +135,7 @@ fn multicall_stash_copy() {
|
||||||
let mut input: Vec<u8> = Vec::new();
|
let mut input: Vec<u8> = Vec::new();
|
||||||
if args.text.is_empty() {
|
if args.text.is_empty() {
|
||||||
if let Err(e) = std::io::stdin().read_to_end(&mut input) {
|
if let Err(e) = std::io::stdin().read_to_end(&mut input) {
|
||||||
eprintln!("stash-copy: failed to read stdin: {e}");
|
eprintln!("failed to read stdin: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -153,8 +153,7 @@ fn multicall_stash_copy() {
|
||||||
}
|
}
|
||||||
if let Some(seat) = args.seat.as_deref() {
|
if let Some(seat) = args.seat.as_deref() {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"stash-copy: --seat is not supported by stash (using default seat: \
|
"'--seat' is not supported by stash (using default seat: {seat})"
|
||||||
{seat})"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if args.omit_additional_text_mime_types {
|
if args.omit_additional_text_mime_types {
|
||||||
|
|
@ -170,13 +169,13 @@ fn multicall_stash_copy() {
|
||||||
if args.clear {
|
if args.clear {
|
||||||
// Clear clipboard by setting empty contents
|
// Clear clipboard by setting empty contents
|
||||||
if let Err(e) = opts.copy(Source::Bytes(Vec::new().into()), mime_type) {
|
if let Err(e) = opts.copy(Source::Bytes(Vec::new().into()), mime_type) {
|
||||||
log::error!("stash-copy: failed to clear clipboard: {e}");
|
log::error!("failed to clear clipboard: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Err(e) = opts.copy(Source::Bytes(input.into()), mime_type) {
|
if let Err(e) = opts.copy(Source::Bytes(input.into()), mime_type) {
|
||||||
log::error!("stash-copy: failed to copy to clipboard: {e}");
|
log::error!("failed to copy to clipboard: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -220,19 +219,18 @@ fn multicall_stash_paste() {
|
||||||
|
|
||||||
if let Some(seat) = args.seat.as_deref() {
|
if let Some(seat) = args.seat.as_deref() {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"stash-paste: --seat is not supported by stash (using default seat: \
|
"'--seat' is not supported by stash (using default seat: {seat})"
|
||||||
{seat})"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.list_types {
|
if args.list_types {
|
||||||
match get_contents(clipboard, Seat::Unspecified, MimeType::Text) {
|
match get_contents(clipboard, Seat::Unspecified, MimeType::Text) {
|
||||||
Ok((_reader, available_types)) => {
|
Ok((_reader, available_types)) => {
|
||||||
print!("{available_types}");
|
log::info!("{available_types}");
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("stash-paste: failed to list types: {e}");
|
log::error!("failed to list types: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -258,15 +256,13 @@ fn multicall_stash_paste() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("stash-paste: failed to read clipboard: {e}");
|
log::error!("failed to read clipboard: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(Error::NoSeats) => {
|
Err(Error::NoSeats) => {
|
||||||
log::error!(
|
log::error!("no seats available (is a Wayland compositor running?)");
|
||||||
"stash-paste: no seats available (is a Wayland compositor running?)"
|
|
||||||
);
|
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
},
|
},
|
||||||
Err(Error::ClipboardEmpty) => {
|
Err(Error::ClipboardEmpty) => {
|
||||||
|
|
@ -275,13 +271,11 @@ fn multicall_stash_paste() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(Error::NoMimeType) => {
|
Err(Error::NoMimeType) => {
|
||||||
log::error!(
|
log::error!("clipboard does not contain requested MIME type");
|
||||||
"stash-paste: clipboard does not contain requested MIME type"
|
|
||||||
);
|
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("stash-paste: clipboard error: {e}");
|
log::error!("clipboard error: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue