Remove 'arboard' (#4174)

This commit is contained in:
JT
2021-12-02 08:48:03 +13:00
committed by GitHub
parent e6e6b730f3
commit 89cbfd758d
10 changed files with 142 additions and 612 deletions

559
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -89,7 +89,6 @@ extra = [
"inc", "inc",
"tree", "tree",
"textview", "textview",
"clipboard-cli",
"trash-support", "trash-support",
"uuid-support", "uuid-support",
"start", "start",
@ -113,7 +112,6 @@ textview = ["nu_plugin_textview"]
binaryview = ["nu_plugin_binaryview"] binaryview = ["nu_plugin_binaryview"]
bson = ["nu_plugin_from_bson", "nu_plugin_to_bson"] bson = ["nu_plugin_from_bson", "nu_plugin_to_bson"]
chart = ["nu_plugin_chart"] chart = ["nu_plugin_chart"]
clipboard-cli = ["nu-command/clipboard-cli"]
query-json = ["nu_plugin_query_json"] query-json = ["nu_plugin_query_json"]
s3 = ["nu_plugin_s3"] s3 = ["nu_plugin_s3"]
selector = ["nu_plugin_selector"] selector = ["nu_plugin_selector"]

View File

@ -31,7 +31,6 @@ nu-pretty-hex = { version = "0.40.0", path="../nu-pretty-hex" }
url = "2.2.1" url = "2.2.1"
mime = "0.3.16" mime = "0.3.16"
Inflector = "0.11" Inflector = "0.11"
arboard = { version = "2.0.1", optional = true }
base64 = "0.13.0" base64 = "0.13.0"
bigdecimal = { version = "0.3.0", features = ["serde"] } bigdecimal = { version = "0.3.0", features = ["serde"] }
calamine = "0.18.0" calamine = "0.18.0"
@ -113,7 +112,6 @@ quickcheck_macros = "1.0.0"
hamcrest2 = "0.3.0" hamcrest2 = "0.3.0"
[features] [features]
clipboard-cli = ["arboard"]
rustyline-support = ["rustyline"] rustyline-support = ["rustyline"]
stable = [] stable = []
trash-support = ["trash"] trash-support = ["trash"]

View File

@ -221,11 +221,6 @@ fn features_enabled() -> Vec<String> {
names.push("zip".to_string()); names.push("zip".to_string());
} }
#[cfg(feature = "clipboard-cli")]
{
names.push("clipboard-cli".to_string());
}
#[cfg(feature = "trash-support")] #[cfg(feature = "trash-support")]
{ {
names.push("trash".to_string()); names.push("trash".to_string());

View File

@ -1,105 +0,0 @@
use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{Signature, Value};
use arboard::Clipboard;
pub struct Clip;
impl WholeStreamCommand for Clip {
fn name(&self) -> &str {
"clip"
}
fn signature(&self) -> Signature {
Signature::build("clip")
}
fn usage(&self) -> &str {
"Copy the contents of the pipeline to the copy/paste buffer."
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
clip(args)
}
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Save text to the clipboard",
example: "echo 'secret value' | clip",
result: None,
},
Example {
description: "Save numbers to the clipboard",
example: "random integer 10000000..99999999 | clip",
result: None,
},
]
}
}
pub fn clip(args: CommandArgs) -> Result<ActionStream, ShellError> {
let input = args.input;
let name = args.call_info.name_tag;
let values: Vec<Value> = input.collect();
if let Ok(mut clip_context) = Clipboard::new() {
let mut new_copy_data = String::new();
if !values.is_empty() {
let mut first = true;
for i in &values {
if !first {
new_copy_data.push('\n');
} else {
first = false;
}
let string: String = i.convert_to_string();
if string.is_empty() {
return Err(ShellError::labeled_error(
"Unable to convert to string",
"Unable to convert to string",
name,
));
}
new_copy_data.push_str(&string);
}
}
match clip_context.set_text(new_copy_data) {
Ok(_) => {}
Err(_) => {
return Err(ShellError::labeled_error(
"Could not set contents of clipboard",
"could not set contents of clipboard",
name,
));
}
}
} else {
return Err(ShellError::labeled_error(
"Could not open clipboard",
"could not open clipboard",
name,
));
}
Ok(ActionStream::empty())
}
#[cfg(test)]
mod tests {
use super::Clip;
use super::ShellError;
#[test]
fn examples_work_as_expected() -> Result<(), ShellError> {
use crate::examples::test as test_examples;
test_examples(Clip {})
}
}

View File

@ -1,13 +1,9 @@
mod ansi; mod ansi;
mod benchmark; mod benchmark;
mod clear; mod clear;
#[cfg(feature = "clipboard-cli")]
mod clip;
mod du; mod du;
mod exec; mod exec;
mod kill; mod kill;
#[cfg(feature = "clipboard-cli")]
mod paste;
mod pwd; mod pwd;
mod run_external; mod run_external;
mod sleep; mod sleep;
@ -17,13 +13,9 @@ mod which_;
pub use ansi::*; pub use ansi::*;
pub use benchmark::Benchmark; pub use benchmark::Benchmark;
pub use clear::Clear; pub use clear::Clear;
#[cfg(feature = "clipboard-cli")]
pub use clip::Clip;
pub use du::Du; pub use du::Du;
pub use exec::Exec; pub use exec::Exec;
pub use kill::Kill; pub use kill::Kill;
#[cfg(feature = "clipboard-cli")]
pub use paste::Paste;
pub use pwd::Pwd; pub use pwd::Pwd;
pub use run_external::RunExternalCommand; pub use run_external::RunExternalCommand;
pub use sleep::Sleep; pub use sleep::Sleep;

View File

@ -1,61 +0,0 @@
use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue};
use arboard::Clipboard;
pub struct Paste;
impl WholeStreamCommand for Paste {
fn name(&self) -> &str {
"paste"
}
fn signature(&self) -> Signature {
Signature::build("paste")
}
fn usage(&self) -> &str {
"Paste contents from the clipboard"
}
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
paste(args)
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Paste text from your clipboard",
example: "echo 'secret value' | clip | paste",
result: Some(vec![UntaggedValue::Primitive(Primitive::String(
"secret value".to_owned(),
))
.into_value(Tag::default())]),
}]
}
}
pub fn paste(args: CommandArgs) -> Result<ActionStream, ShellError> {
let name = args.call_info.name_tag;
if let Ok(mut clip_context) = Clipboard::new() {
match clip_context.get_text() {
Ok(out) => Ok(ActionStream::one(ReturnSuccess::value(
UntaggedValue::Primitive(Primitive::String(out)),
))),
Err(_) => Err(ShellError::labeled_error(
"Could not get contents of clipboard",
"could not get contents of clipboard",
name,
)),
}
} else {
Err(ShellError::labeled_error(
"Could not open clipboard",
"could not open clipboard",
name,
))
}
}

View File

@ -366,14 +366,6 @@ pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Bo
whole_stream_command(DataFrameCumulative), whole_stream_command(DataFrameCumulative),
whole_stream_command(DataFrameRename), whole_stream_command(DataFrameRename),
]); ]);
#[cfg(feature = "clipboard-cli")]
{
context.add_commands(vec![
whole_stream_command(crate::commands::Clip),
whole_stream_command(crate::commands::Paste),
]);
}
} }
Ok(context) Ok(context)

View File

@ -4,7 +4,7 @@ description = "A converter plugin to the mp4 format for Nushell"
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"
name = "nu_plugin_from_mp4" name = "nu_plugin_from_mp4"
version = "0.1.0" version = "0.40.0"
[lib] [lib]
doctest = false doctest = false

View File

@ -208,7 +208,7 @@ pub fn css(selector: &str) -> ScraperSelector {
mod tests { mod tests {
use super::*; use super::*;
const SIMPLE_LIST: &'static str = r#" const SIMPLE_LIST: &str = r#"
<ul> <ul>
<li>Coffee</li> <li>Coffee</li>
<li>Tea</li> <li>Tea</li>