mirror of
https://github.com/nushell/nushell.git
synced 2025-02-02 11:39:55 +01:00
Convert to string before clip (#2624)
This commit is contained in:
parent
66061192f8
commit
e4c6336bd4
@ -32,11 +32,18 @@ impl WholeStreamCommand for Clip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![
|
||||||
description: "Save text to the clipboard",
|
Example {
|
||||||
example: "echo 'secret value' | clip",
|
description: "Save text to the clipboard",
|
||||||
result: None,
|
example: "echo 'secret value' | clip",
|
||||||
}]
|
result: None,
|
||||||
|
},
|
||||||
|
Example {
|
||||||
|
description: "Save numbers to the clipboard",
|
||||||
|
example: "random integer 10000000..99999999 | clip",
|
||||||
|
result: None,
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,16 +68,14 @@ pub async fn clip(
|
|||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let string: String = match i.as_string() {
|
let string: String = i.convert_to_string();
|
||||||
Ok(string) => string.to_string(),
|
if string.is_empty() {
|
||||||
Err(_) => {
|
return Err(ShellError::labeled_error(
|
||||||
return Err(ShellError::labeled_error(
|
"Unable to convert to string",
|
||||||
"Given non-string data",
|
"Unable to convert to string",
|
||||||
"expected strings from pipeline",
|
name,
|
||||||
name,
|
));
|
||||||
))
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
new_copy_data.push_str(&string);
|
new_copy_data.push_str(&string);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user