mirror of
https://github.com/nushell/nushell.git
synced 2025-04-09 21:28:55 +02:00
last is working also with the hard coded length, need to figure out how to get the length of the input
This commit is contained in:
parent
7e66aca18e
commit
3625324bad
@ -2,8 +2,9 @@ use nu_engine::CallExt;
|
|||||||
|
|
||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||||
use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape, Value};
|
use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value};
|
||||||
//use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value};
|
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Last;
|
pub struct Last;
|
||||||
@ -34,6 +35,7 @@ impl Command for Last {
|
|||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let rows: Option<i64> = call.opt(engine_state, stack, 0)?;
|
let rows: Option<i64> = call.opt(engine_state, stack, 0)?;
|
||||||
|
|
||||||
|
/*
|
||||||
let vlength = length(input)?;
|
let vlength = length(input)?;
|
||||||
dbg!(vlength);
|
dbg!(vlength);
|
||||||
|
|
||||||
@ -50,23 +52,25 @@ impl Command for Last {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dbg!(beginning_rows_to_skip);
|
dbg!(beginning_rows_to_skip);
|
||||||
|
*/
|
||||||
|
|
||||||
// let iter = v.into_iter().skip(beginning_rows_to_skip);
|
let beginning_rows_to_skip = 2;
|
||||||
|
|
||||||
//dbg!(input.clone());
|
|
||||||
/*
|
|
||||||
match input {
|
match input {
|
||||||
PipelineData::Stream(stream) => Ok(stream.into_pipeline_data()),
|
PipelineData::Stream(stream) => Ok(stream
|
||||||
PipelineData::Value(Value::List { vals, .. }) => {
|
.skip(beginning_rows_to_skip.try_into().unwrap())
|
||||||
Ok(vals.into_iter().into_pipeline_data())
|
.into_pipeline_data()),
|
||||||
}
|
PipelineData::Value(Value::List { vals, .. }) => Ok(vals
|
||||||
|
.into_iter()
|
||||||
|
.skip(beginning_rows_to_skip.try_into().unwrap())
|
||||||
|
.into_pipeline_data()),
|
||||||
_ => {
|
_ => {
|
||||||
dbg!("Fall to the bottom");
|
dbg!("Fall to the bottom");
|
||||||
Ok(PipelineData::Value(Value::Nothing { span: call.head }))
|
Ok(PipelineData::Value(Value::Nothing { span: call.head }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
Ok(PipelineData::Value(Value::Nothing { span: call.head }))
|
// Ok(PipelineData::Value(Value::Nothing { span: call.head }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user