mirror of
https://github.com/nushell/nushell
synced 2025-01-15 14:44:14 +00:00
add in an example
This commit is contained in:
parent
4b31fe1924
commit
9baf720156
1 changed files with 26 additions and 1 deletions
|
@ -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 a new issue