2019-06-01 05:43:59 +02:00
|
|
|
use crate::errors::ShellError;
|
2019-07-12 21:22:08 +02:00
|
|
|
use crate::object::Value;
|
2019-06-01 05:43:59 +02:00
|
|
|
use crate::prelude::*;
|
|
|
|
|
|
|
|
pub fn trim(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|
|
|
let input = args.input;
|
|
|
|
|
|
|
|
Ok(input
|
2019-07-03 22:31:15 +02:00
|
|
|
.values
|
2019-07-09 06:31:26 +02:00
|
|
|
.map(move |v| {
|
|
|
|
let string = String::extract(&v)?;
|
2019-08-05 10:54:29 +02:00
|
|
|
ReturnSuccess::value(Value::string(string.trim()).simple_spanned(v.span()))
|
2019-07-09 06:31:26 +02:00
|
|
|
})
|
2019-07-03 22:31:15 +02:00
|
|
|
.to_output_stream())
|
2019-06-01 05:43:59 +02:00
|
|
|
}
|