mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
parent
5043367d11
commit
d7ff9fb7b7
3 changed files with 20 additions and 0 deletions
|
@ -56,6 +56,7 @@ pub async fn cli() -> Result<(), Box<Error>> {
|
||||||
command("split-row", split_row::split_row),
|
command("split-row", split_row::split_row),
|
||||||
command("reject", reject::reject),
|
command("reject", reject::reject),
|
||||||
command("select", select::select),
|
command("select", select::select),
|
||||||
|
command("trim", trim::trim),
|
||||||
command("to-array", to_array::to_array),
|
command("to-array", to_array::to_array),
|
||||||
command("to-json", to_json::to_json),
|
command("to-json", to_json::to_json),
|
||||||
Arc::new(Where),
|
Arc::new(Where),
|
||||||
|
|
|
@ -17,6 +17,7 @@ crate mod split_row;
|
||||||
crate mod take;
|
crate mod take;
|
||||||
crate mod to_array;
|
crate mod to_array;
|
||||||
crate mod to_json;
|
crate mod to_json;
|
||||||
|
crate mod trim;
|
||||||
crate mod view;
|
crate mod view;
|
||||||
crate mod where_;
|
crate mod where_;
|
||||||
|
|
||||||
|
|
18
src/commands/trim.rs
Normal file
18
src/commands/trim.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
use crate::errors::ShellError;
|
||||||
|
use crate::object::{Primitive, Value};
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
// TODO: "Amount remaining" wrapper
|
||||||
|
|
||||||
|
pub fn trim(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
|
let input = args.input;
|
||||||
|
|
||||||
|
Ok(input
|
||||||
|
.map(move |v| match v {
|
||||||
|
Value::Primitive(Primitive::String(s)) => {
|
||||||
|
ReturnValue::Value(Value::Primitive(Primitive::String(s.trim().to_string())))
|
||||||
|
}
|
||||||
|
x => ReturnValue::Value(x),
|
||||||
|
})
|
||||||
|
.boxed())
|
||||||
|
}
|
Loading…
Reference in a new issue