Merge pull request #281 from jonathandturner/improve_arrays

Add from_array and improve array viewing
This commit is contained in:
Jonathan Turner
2019-08-12 18:16:08 +12:00
committed by GitHub
6 changed files with 51 additions and 5 deletions

14
src/commands/debug.rs Normal file
View File

@@ -0,0 +1,14 @@
use crate::errors::ShellError;
use crate::prelude::*;
pub fn debug(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let input = args.input;
Ok(input
.values
.map(|v| {
println!("{:?}", v);
ReturnSuccess::value(v)
})
.to_output_stream())
}

View File

@@ -0,0 +1,21 @@
use crate::object::Value;
use crate::prelude::*;
pub fn from_array(
args: CommandArgs,
_registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> {
let stream = args
.input
.values
.map(|item| match item {
Tagged {
item: Value::List(vec),
..
} => VecDeque::from(vec),
x => VecDeque::from(vec![x]),
})
.flatten();
Ok(stream.to_output_stream())
}