forked from extern/nushell
parent
5043367d11
commit
d7ff9fb7b7
@ -56,6 +56,7 @@ pub async fn cli() -> Result<(), Box<Error>> {
|
||||
command("split-row", split_row::split_row),
|
||||
command("reject", reject::reject),
|
||||
command("select", select::select),
|
||||
command("trim", trim::trim),
|
||||
command("to-array", to_array::to_array),
|
||||
command("to-json", to_json::to_json),
|
||||
Arc::new(Where),
|
||||
|
@ -17,6 +17,7 @@ crate mod split_row;
|
||||
crate mod take;
|
||||
crate mod to_array;
|
||||
crate mod to_json;
|
||||
crate mod trim;
|
||||
crate mod view;
|
||||
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 New Issue
Block a user