nushell/src/commands/trim.rs

18 lines
437 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::*;
// TODO: "Amount remaining" wrapper
pub fn trim(args: CommandArgs) -> Result<OutputStream, ShellError> {
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
}