forked from extern/nushell
Switch tables to list/streams of records
This commit is contained in:
@ -52,7 +52,7 @@ impl Command for Each {
|
||||
.into_value_stream(),
|
||||
span: call.head,
|
||||
}),
|
||||
Value::List { val, .. } => Ok(Value::ValueStream {
|
||||
Value::List { vals: val, .. } => Ok(Value::ValueStream {
|
||||
stream: val
|
||||
.into_iter()
|
||||
.map(move |x| {
|
||||
@ -95,8 +95,6 @@ impl Command for Each {
|
||||
.into_value_stream(),
|
||||
span: call.head,
|
||||
}),
|
||||
Value::RowStream { .. } => panic!("iterating row streams is not yet supported"),
|
||||
Value::Table { .. } => panic!("table iteration not yet supported"),
|
||||
x => {
|
||||
//TODO: we need to watch to make sure this is okay
|
||||
let engine_state = context.engine_state.borrow();
|
||||
|
@ -68,8 +68,8 @@ impl Command for For {
|
||||
.into_value_stream(),
|
||||
span: call.head,
|
||||
}),
|
||||
Value::List { val, .. } => Ok(Value::List {
|
||||
val: val
|
||||
Value::List { vals: val, .. } => Ok(Value::List {
|
||||
vals: val
|
||||
.into_iter()
|
||||
.map(move |x| {
|
||||
let engine_state = context.engine_state.borrow();
|
||||
|
@ -24,15 +24,7 @@ impl Command for Length {
|
||||
input: Value,
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
match input {
|
||||
Value::List { val, .. } => {
|
||||
let length = val.len();
|
||||
|
||||
Ok(Value::Int {
|
||||
val: length as i64,
|
||||
span: call.head,
|
||||
})
|
||||
}
|
||||
Value::Table { val, .. } => {
|
||||
Value::List { vals: val, .. } => {
|
||||
let length = val.len();
|
||||
|
||||
Ok(Value::Int {
|
||||
@ -48,14 +40,6 @@ impl Command for Length {
|
||||
span: call.head,
|
||||
})
|
||||
}
|
||||
Value::RowStream { stream, .. } => {
|
||||
let length = stream.count();
|
||||
|
||||
Ok(Value::Int {
|
||||
val: length as i64,
|
||||
span: call.head,
|
||||
})
|
||||
}
|
||||
Value::Nothing { .. } => Ok(Value::Int {
|
||||
val: 0,
|
||||
span: call.head,
|
||||
|
Reference in New Issue
Block a user