mirror of
https://github.com/nushell/nushell.git
synced 2024-12-13 10:41:52 +01:00
b2c5af457e
This improves incremental build time when working on what was previously the root package. For example, previously all plugins would be rebuilt with a change to `src/commands/classified/external.rs`, but now only `nu-cli` will have to be rebuilt (and anything that depends on it).
48 lines
1.0 KiB
Rust
48 lines
1.0 KiB
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::context::CommandRegistry;
|
|
use crate::prelude::*;
|
|
use nu_errors::ShellError;
|
|
use nu_protocol::{Signature, SyntaxShape};
|
|
use nu_source::Tagged;
|
|
|
|
pub struct Skip;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct SkipArgs {
|
|
rows: Option<Tagged<usize>>,
|
|
}
|
|
|
|
impl WholeStreamCommand for Skip {
|
|
fn name(&self) -> &str {
|
|
"skip"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("skip").optional("rows", SyntaxShape::Int, "how many rows to skip")
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Skip some number of rows."
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
args: CommandArgs,
|
|
registry: &CommandRegistry,
|
|
) -> Result<OutputStream, ShellError> {
|
|
args.process(registry, skip)?.run()
|
|
}
|
|
}
|
|
|
|
fn skip(SkipArgs { rows }: SkipArgs, context: RunnableContext) -> Result<OutputStream, ShellError> {
|
|
let rows_desired = if let Some(quantity) = rows {
|
|
*quantity
|
|
} else {
|
|
1
|
|
};
|
|
|
|
Ok(OutputStream::from_input(
|
|
context.input.values.skip(rows_desired),
|
|
))
|
|
}
|