Replace clipboard with arboard (#2832)

This commit is contained in:
Artúr Kovács
2020-12-30 18:16:02 +01:00
committed by GitHub
parent f449baf8de
commit 79476a5cb2
3 changed files with 130 additions and 36 deletions

View File

@ -24,6 +24,7 @@ nu-test-support = {version = "0.24.2", path = "../nu-test-support"}
nu-value-ext = {version = "0.24.2", path = "../nu-value-ext"}
ansi_term = "0.12.1"
arboard = {version = "1.1.0", optional = true}
async-recursion = "0.3.1"
async-trait = "0.1.40"
base64 = "0.13.0"
@ -34,7 +35,6 @@ calamine = "0.16.1"
chrono = {version = "0.4.15", features = ["serde"]}
chrono-tz = "0.5.3"
clap = "2.33.3"
clipboard = {version = "0.5.0", optional = true}
codespan-reporting = "0.9.5"
csv = "1.1.3"
ctrlc = {version = "3.1.6", optional = true}
@ -126,7 +126,7 @@ quickcheck = "0.9.2"
quickcheck_macros = "0.9.1"
[features]
clipboard-cli = ["clipboard"]
clipboard-cli = ["arboard"]
rich-benchmark = ["heim"]
rustyline-support = ["rustyline"]
stable = []

View File

@ -4,7 +4,7 @@ use futures::stream::StreamExt;
use nu_errors::ShellError;
use nu_protocol::{Signature, Value};
use clipboard::{ClipboardContext, ClipboardProvider};
use arboard::Clipboard;
pub struct Clip;
@ -47,8 +47,7 @@ pub async fn clip(args: CommandArgs) -> Result<OutputStream, ShellError> {
let name = args.call_info.name_tag.clone();
let values: Vec<Value> = input.collect().await;
if let Ok(clip_context) = ClipboardProvider::new() {
let mut clip_context: ClipboardContext = clip_context;
if let Ok(mut clip_context) = Clipboard::new() {
let mut new_copy_data = String::new();
if !values.is_empty() {
@ -73,7 +72,7 @@ pub async fn clip(args: CommandArgs) -> Result<OutputStream, ShellError> {
}
}
match clip_context.set_contents(new_copy_data) {
match clip_context.set_text(new_copy_data) {
Ok(_) => {}
Err(_) => {
return Err(ShellError::labeled_error(