nu_cmd_lang/core_commands/
continue_.rs1use nu_engine::command_prelude::*;
2use nu_protocol::engine::CommandType;
3
4#[derive(Clone)]
5pub struct Continue;
6
7impl Command for Continue {
8 fn name(&self) -> &str {
9 "continue"
10 }
11
12 fn description(&self) -> &str {
13 "Continue a loop from the next iteration."
14 }
15
16 fn signature(&self) -> nu_protocol::Signature {
17 Signature::build("continue")
18 .input_output_types(vec![(Type::Nothing, Type::Nothing)])
19 .category(Category::Core)
20 }
21
22 fn extra_description(&self) -> &str {
23 r#"This command is a parser keyword. For details, check:
24 https://www.nushell.sh/book/thinking_in_nu.html
25
26 continue can only be used in while, loop, and for loops. It can not be used with each or other filter commands"#
27 }
28
29 fn command_type(&self) -> CommandType {
30 CommandType::Keyword
31 }
32 fn run(
33 &self,
34 _engine_state: &EngineState,
35 _stack: &mut Stack,
36 _call: &Call,
37 _input: PipelineData,
38 ) -> Result<PipelineData, ShellError> {
39 eprintln!(
42 "Tried to execute 'run' for the 'continue' command: this code path should never be reached in IR mode"
43 );
44 unreachable!()
45 }
46
47 fn examples(&self) -> Vec<Example<'_>> {
48 vec![Example {
49 description: "Continue a loop from the next iteration",
50 example: r#"for i in 1..10 { if $i == 5 { continue }; print $i }"#,
51 result: None,
52 }]
53 }
54}