Switch from quale to which, properly optionally import clipboard crates

This commit is contained in:
timvisee 2019-04-05 15:15:05 +02:00
parent 6feea9b463
commit b59650f25d
No known key found for this signature in database
GPG key ID: B8DB720BC383E172
3 changed files with 24 additions and 17 deletions

21
Cargo.lock generated
View file

@ -590,7 +590,6 @@ dependencies = [
"pbr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"prettytable-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"qr2term 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"quale 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rpassword 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
@ -599,6 +598,7 @@ dependencies = [
"toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"urlshortener 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"version-compare 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1280,14 +1280,6 @@ dependencies = [
"checked_int_cast 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quale"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "0.5.2"
@ -2137,6 +2129,15 @@ dependencies = [
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "which"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.2.8"
@ -2343,7 +2344,6 @@ dependencies = [
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
"checksum qr2term 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "358175087ab058962f8f4457864ece0db9685ca5a8938385b5c9e279aa781349"
"checksum qrcode 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3553d8614cd59cede2a00db69bc96ea72dfdd92c041600f06b100f6f2699b26"
"checksum quale 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c46811c513cc64cceb23adc27892b3b3470c1790de117610221b97071de8bc8c"
"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
@ -2439,6 +2439,7 @@ dependencies = [
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
"checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3"
"checksum websocket 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7cc2d74d89f9df981ab41ae624e33cf302fdf456b93455c6a31911a99c9f0bb8"
"checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"

View file

@ -65,6 +65,9 @@ default = [
# Compile with file archiving support
archive = ["tar"]
# Support for putting share URLs in clipboard
clipboard = ["clip", "which"]
# Compile with file history support
history = []
@ -112,7 +115,8 @@ urlshortener = { version = "0.10", default-features = false, optional = true }
version-compare = "0.0.6"
[target.'cfg(target_os = "linux")'.dependencies]
quale = "1.0"
which = { version = "2.0", optional = true }
[target.'cfg(not(target_os = "linux"))'.dependencies]
clipboard = { version = "0.5", optional = true }
# Package is aliased to clip to prevent name collision with clipboard feature
clip = { version = "0.5", optional = true, package = "clipboard" }

View file

@ -1,11 +1,11 @@
#[cfg(all(feature = "clipboard", not(target_os = "linux")))]
extern crate clipboard;
extern crate clip;
extern crate colored;
extern crate directories;
extern crate fs2;
extern crate open;
#[cfg(all(feature = "clipboard", target_os = "linux"))]
extern crate quale;
extern crate which;
use std::borrow::Borrow;
use std::env::{self, current_exe, var_os};
@ -23,7 +23,7 @@ use std::process::{exit, ExitStatus};
use std::process::{Command, Stdio};
#[cfg(all(feature = "clipboard", not(target_os = "linux")))]
use self::clipboard::{ClipboardContext, ClipboardProvider};
use self::clip::{ClipboardContext, ClipboardProvider};
use self::colored::*;
#[cfg(feature = "history")]
use self::directories::ProjectDirs;
@ -39,6 +39,8 @@ use ffsend_api::{
url::Url,
};
use rpassword::prompt_password_stderr;
#[cfg(all(feature = "clipboard", target_os = "linux"))]
use which::which;
use crate::cmd::matcher::MainMatcher;
@ -341,9 +343,9 @@ impl ClipboardType {
ClipboardType::Xclip(Some(path.to_owned()))
} else if let Some(path) = option_env!("XSEL_PATH") {
ClipboardType::Xsel(Some(path.to_owned()))
} else if quale::which("xclip").is_some() {
} else if which("xclip").is_ok() {
ClipboardType::Xclip(None)
} else if quale::which("xsel").is_some() {
} else if which("xsel").is_ok() {
ClipboardType::Xsel(None)
} else {
// TODO: should we error here instead, as no clipboard binary was found?