nushell/src/commands/trim.rs

16 lines
428 B
Rust
Raw Normal View History

2019-06-01 03:43:59 +00:00
use crate::errors::ShellError;
2019-07-12 19:22:08 +00:00
use crate::object::Value;
2019-06-01 03:43:59 +00:00
use crate::prelude::*;
2019-07-23 22:22:11 +00:00
pub fn trim(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
2019-06-01 03:43:59 +00:00
let input = args.input;
Ok(input
.values
2019-07-09 04:31:26 +00:00
.map(move |v| {
let string = String::extract(&v)?;
ReturnSuccess::value(Value::string(string.trim()).spanned(v.span))
})
.to_output_stream())
2019-06-01 03:43:59 +00:00
}