use crate::commands::WholeStreamCommand; use crate::errors::ShellError; use crate::parser::CommandRegistry; use crate::prelude::*; #[derive(Deserialize)] struct NthArgs { amount: Tagged, } pub struct Nth; impl WholeStreamCommand for Nth { fn run( &self, args: CommandArgs, registry: &CommandRegistry, ) -> Result { args.process(registry, nth)?.run() } fn name(&self) -> &str { "nth" } fn signature(&self) -> Signature { Signature::build("nth").required("amount", SyntaxType::Any) } } fn nth( NthArgs { amount }: NthArgs, RunnableContext { input, .. }: RunnableContext, ) -> Result { Ok(OutputStream::from_input( input.values.skip(amount.item as u64).take(1), )) }