nushell/src/commands/trim.rs

19 lines
509 B
Rust
Raw Normal View History

2019-06-01 05:43:59 +02:00
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())
}