nushell/src/commands/trim.rs
Yehuda Katz 70f9e355fd WIP
2019-07-12 19:20:26 -07:00

17 lines
437 B
Rust

use crate::errors::ShellError;
use crate::object::Value;
use crate::prelude::*;
// TODO: "Amount remaining" wrapper
pub fn trim(args: CommandArgs) -> Result<OutputStream, ShellError> {
let input = args.input;
Ok(input
.values
.map(move |v| {
let string = String::extract(&v)?;
ReturnSuccess::value(Value::string(string.trim()).spanned(v.span))
})
.to_output_stream())
}