mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 10:25:42 +02:00
Rust 1.85, edition=2024 (#15741)
This commit is contained in:
@ -3,7 +3,7 @@ authors = ["The Nushell Project Developers"]
|
||||
build = "build.rs"
|
||||
description = "Nushell's core language commands"
|
||||
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
name = "nu-cmd-lang"
|
||||
version = "0.104.1"
|
||||
|
@ -39,7 +39,9 @@ impl Command for Break {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'break' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'break' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use nu_engine::{command_prelude::*, get_eval_block, redirect_env};
|
||||
use nu_protocol::{engine::Closure, DataSource, PipelineMetadata};
|
||||
use nu_protocol::{DataSource, PipelineMetadata, engine::Closure};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Collect;
|
||||
|
@ -48,7 +48,9 @@ impl Command for Const {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'const' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'const' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,9 @@ impl Command for Continue {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'continue' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'continue' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_protocol::{
|
||||
engine::{Closure, StateWorkingSet},
|
||||
BlockId, ByteStreamSource, Category, PipelineMetadata, Signature,
|
||||
engine::{Closure, StateWorkingSet},
|
||||
};
|
||||
use std::any::type_name;
|
||||
#[derive(Clone)]
|
||||
@ -72,8 +72,7 @@ impl Command for Describe {
|
||||
},
|
||||
Example {
|
||||
description: "Describe the type of a record in a detailed way",
|
||||
example:
|
||||
"{shell:'true', uwu:true, features: {bugs:false, multiplatform:true, speed: 10}, fib: [1 1 2 3 5 8], on_save: {|x| $'Saving ($x)'}, first_commit: 2019-05-10, my_duration: (4min + 20sec)} | describe -d",
|
||||
example: "{shell:'true', uwu:true, features: {bugs:false, multiplatform:true, speed: 10}, fib: [1 1 2 3 5 8], on_save: {|x| $'Saving ($x)'}, first_commit: 2019-05-10, my_duration: (4min + 20sec)} | describe -d",
|
||||
result: Some(Value::test_record(record!(
|
||||
"type" => Value::test_string("record"),
|
||||
"detailed_type" => Value::test_string("record<shell: string, uwu: bool, features: record<bugs: bool, multiplatform: bool, speed: int>, fib: list<int>, on_save: closure, first_commit: datetime, my_duration: duration>"),
|
||||
@ -191,32 +190,32 @@ impl Command for Describe {
|
||||
Example {
|
||||
description: "Describe the type of a stream with detailed information",
|
||||
example: "[1 2 3] | each {|i| echo $i} | describe -d",
|
||||
result: None // Give "Running external commands not supported" error
|
||||
// result: Some(Value::test_record(record!(
|
||||
// "type" => Value::test_string("stream"),
|
||||
// "origin" => Value::test_string("nushell"),
|
||||
// "subtype" => Value::test_record(record!(
|
||||
// "type" => Value::test_string("list"),
|
||||
// "length" => Value::test_int(3),
|
||||
// "values" => Value::test_list(vec![
|
||||
// Value::test_string("int"),
|
||||
// Value::test_string("int"),
|
||||
// Value::test_string("int"),
|
||||
// ])
|
||||
// ))
|
||||
// ))),
|
||||
result: None, // Give "Running external commands not supported" error
|
||||
// result: Some(Value::test_record(record!(
|
||||
// "type" => Value::test_string("stream"),
|
||||
// "origin" => Value::test_string("nushell"),
|
||||
// "subtype" => Value::test_record(record!(
|
||||
// "type" => Value::test_string("list"),
|
||||
// "length" => Value::test_int(3),
|
||||
// "values" => Value::test_list(vec![
|
||||
// Value::test_string("int"),
|
||||
// Value::test_string("int"),
|
||||
// Value::test_string("int"),
|
||||
// ])
|
||||
// ))
|
||||
// ))),
|
||||
},
|
||||
Example {
|
||||
description: "Describe a stream of data, collecting it first",
|
||||
example: "[1 2 3] | each {|i| echo $i} | describe",
|
||||
result: None // Give "Running external commands not supported" error
|
||||
// result: Some(Value::test_string("list<int> (stream)")),
|
||||
result: None, // Give "Running external commands not supported" error
|
||||
// result: Some(Value::test_string("list<int> (stream)")),
|
||||
},
|
||||
Example {
|
||||
description: "Describe the input but do not collect streams",
|
||||
example: "[1 2 3] | each {|i| echo $i} | describe --no-collect",
|
||||
result: None // Give "Running external commands not supported" error
|
||||
// result: Some(Value::test_string("stream")),
|
||||
result: None, // Give "Running external commands not supported" error
|
||||
// result: Some(Value::test_string("stream")),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use nu_engine::{command_prelude::*, get_eval_block_with_early_return, redirect_e
|
||||
#[cfg(feature = "os")]
|
||||
use nu_protocol::process::{ChildPipe, ChildProcess};
|
||||
use nu_protocol::{
|
||||
engine::Closure, shell_error::io::IoError, ByteStream, ByteStreamSource, OutDest,
|
||||
ByteStream, ByteStreamSource, OutDest, engine::Closure, shell_error::io::IoError,
|
||||
};
|
||||
|
||||
use std::{
|
||||
|
@ -63,8 +63,7 @@ little reason to use this over just writing the values as-is."#
|
||||
)),
|
||||
},
|
||||
Example {
|
||||
description:
|
||||
"Returns the piped-in value, by using the special $in variable to obtain it.",
|
||||
description: "Returns the piped-in value, by using the special $in variable to obtain it.",
|
||||
example: "echo $in",
|
||||
result: None,
|
||||
},
|
||||
|
@ -76,8 +76,7 @@ impl Command for ErrorMake {
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description:
|
||||
"Create a custom error for a custom command that shows the span of the argument",
|
||||
description: "Create a custom error for a custom command that shows the span of the argument",
|
||||
example: r#"def foo [x] {
|
||||
error make {
|
||||
msg: "this is fishy"
|
||||
@ -106,7 +105,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: throw_span,
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -119,7 +118,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: Some(span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
None => {
|
||||
return ShellError::GenericError {
|
||||
@ -128,7 +127,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: Some(span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -146,7 +145,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: Some(span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
// correct return: no label
|
||||
None => {
|
||||
@ -156,7 +155,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: throw_span,
|
||||
help,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -180,7 +179,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: Some(label_span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
None => {
|
||||
return ShellError::GenericError {
|
||||
@ -189,7 +188,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: Some(label_span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@ -202,7 +201,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: Some(value.span()),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
// correct return: label, no span
|
||||
None => {
|
||||
@ -212,7 +211,7 @@ fn make_other_error(value: &Value, throw_span: Option<Span>) -> ShellError {
|
||||
span: throw_span,
|
||||
help,
|
||||
inner: vec![],
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,9 @@ impl Command for For {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'for' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'for' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,9 @@ impl Command for If {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'if' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'if' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use nu_engine::command_prelude::*;
|
||||
use nu_protocol::{engine::StateWorkingSet, ByteStreamSource, OutDest};
|
||||
use nu_protocol::{ByteStreamSource, OutDest, engine::StateWorkingSet};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Ignore;
|
||||
|
@ -48,7 +48,9 @@ impl Command for Let {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'let' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'let' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,9 @@ impl Command for Loop {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'loop' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'loop' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,9 @@ impl Command for Match {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'match' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'match' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
@ -56,8 +58,7 @@ impl Command for Match {
|
||||
},
|
||||
Example {
|
||||
description: "Match against alternative values",
|
||||
example:
|
||||
"match 'three' { 1 | 'one' => '-', 2 | 'two' => '--', 3 | 'three' => '---' }",
|
||||
example: "match 'three' { 1 | 'one' => '-', 2 | 'two' => '--', 3 | 'three' => '---' }",
|
||||
result: Some(Value::test_string("---")),
|
||||
},
|
||||
Example {
|
||||
|
@ -48,7 +48,9 @@ impl Command for Mut {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'mut' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'mut' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ impl Command for OverlayHide {
|
||||
return Err(ShellError::EnvVarNotFoundAtRuntime {
|
||||
envvar_name: name.item,
|
||||
span: name.span,
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use nu_engine::{
|
||||
command_prelude::*, find_in_dirs_env, get_dirs_var_from_call, get_eval_block, redirect_env,
|
||||
};
|
||||
use nu_parser::trim_quotes_str;
|
||||
use nu_protocol::{ast::Expr, engine::CommandType, ModuleId};
|
||||
use nu_protocol::{ModuleId, ast::Expr, engine::CommandType};
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
|
@ -42,7 +42,9 @@ impl Command for Return {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'return' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'return' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,9 @@ impl Command for Try {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'try' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'try' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,9 @@ impl Command for While {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
// This is compiled specially by the IR compiler. The code here is never used when
|
||||
// running in IR mode.
|
||||
eprintln!("Tried to execute 'run' for the 'while' command: this code path should never be reached in IR mode");
|
||||
eprintln!(
|
||||
"Tried to execute 'run' for the 'while' command: this code path should never be reached in IR mode"
|
||||
);
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use itertools::Itertools;
|
||||
use nu_engine::{command_prelude::*, compile};
|
||||
use nu_protocol::{
|
||||
ast::Block, debugger::WithoutDebug, engine::StateWorkingSet, report_shell_error, Range,
|
||||
Range, ast::Block, debugger::WithoutDebug, engine::StateWorkingSet, report_shell_error,
|
||||
};
|
||||
use std::{
|
||||
sync::Arc,
|
||||
@ -163,13 +163,9 @@ pub fn check_example_evaluates_to_expected_output(
|
||||
let expected = DebuggableValue(expected);
|
||||
let result = DebuggableValue(&result);
|
||||
assert_eq!(
|
||||
result,
|
||||
expected,
|
||||
result, expected,
|
||||
"Error: The result of example '{}' for the command '{}' differs from the expected value.\n\nExpected: {:?}\nActual: {:?}\n",
|
||||
example.description,
|
||||
cmd_name,
|
||||
expected,
|
||||
result,
|
||||
example.description, cmd_name, expected, result,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ mod test_examples {
|
||||
Break, Collect, Def, Describe, Echo, ExportCommand, ExportDef, If, Let, Module, Mut, Use,
|
||||
};
|
||||
use nu_protocol::{
|
||||
engine::{Command, EngineState, StateWorkingSet},
|
||||
Type, Value,
|
||||
engine::{Command, EngineState, StateWorkingSet},
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use nu_protocol::{engine::StateWorkingSet, Span};
|
||||
use nu_protocol::{Span, engine::StateWorkingSet};
|
||||
use quickcheck_macros::quickcheck;
|
||||
|
||||
#[quickcheck]
|
||||
|
Reference in New Issue
Block a user