forked from extern/nushell
add in an example
This commit is contained in:
parent
4b31fe1924
commit
9baf720156
@ -2,7 +2,9 @@ use nu_engine::CallExt;
|
||||
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape};
|
||||
use nu_protocol::{
|
||||
Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Value,
|
||||
};
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -25,6 +27,17 @@ impl Command for Last {
|
||||
"Show only the last number of rows."
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
example: "[1,2,3] | last 2",
|
||||
description: "Get the last 2 items",
|
||||
result: Some(Value::List {
|
||||
vals: vec![Value::test_int(2), Value::test_int(3)],
|
||||
span: Span::unknown(),
|
||||
}),
|
||||
}]
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
@ -58,3 +71,15 @@ fn rows_to_skip(count: i64, rows: Option<i64>) -> i64 {
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(Last {})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user