mirror of
https://github.com/nushell/nushell.git
synced 2025-08-17 22:59:52 +02:00
Add from_array and improve array viewing
This commit is contained in:
14
src/commands/debug.rs
Normal file
14
src/commands/debug.rs
Normal 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())
|
||||
}
|
21
src/commands/from_array.rs
Normal file
21
src/commands/from_array.rs
Normal 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())
|
||||
}
|
Reference in New Issue
Block a user