mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 08:49:33 +02:00
Remove math eval
command (#7284)
Reasoning: Most missing math commands are implemented with #7258. The `meval` crate itself declares that it doesn't strive to stringent standards (https://docs.rs/meval/latest/meval/#related-projects). For example no particular special casing or transformations are performed to ensure numerical stability. It uses the same rust `std` library functions we use or have access to (and `f64`). While the command call syntax in nushell may be a bit more verbose, having a single source of truth and common commands is beneficial. Furthermore the `math` commands can themselves implement broadcasting over lists (or table columns). Closes #7073 Removed dependencies: - `meval` - `nom 1.2.4` (duplicate) User-Facing Changes: Scripts using `math eval` will break. We remove a further `eval` like behavior to get results through runtime evaluation (albeit limited in scope) Tests: - Updated tests that internally used `math eval`. - Removed one test that primarily used `math eval` to obtain a result from `str join`
This commit is contained in:
committed by
GitHub
parent
429127793f
commit
9bc4e6794d
40
crates/nu-command/src/deprecated/math_eval.rs
Normal file
40
crates/nu-command/src/deprecated/math_eval.rs
Normal file
@ -0,0 +1,40 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
|
||||
impl Command for SubCommand {
|
||||
fn name(&self) -> &str {
|
||||
"math eval"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math eval")
|
||||
.rest(
|
||||
"ignored",
|
||||
SyntaxShape::Any,
|
||||
"arguments to deprecated command are ignored",
|
||||
)
|
||||
.category(Category::Deprecated)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Deprecated command"
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
_stack: &mut Stack,
|
||||
call: &Call,
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
Err(ShellError::DeprecatedCommand(
|
||||
self.name().to_string(),
|
||||
"math <subcommands>".to_string(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
mod deprecated_commands;
|
||||
mod hash_base64;
|
||||
mod math_eval;
|
||||
mod source;
|
||||
mod str_datetime;
|
||||
mod str_decimal;
|
||||
@ -8,6 +9,7 @@ mod str_int;
|
||||
|
||||
pub use deprecated_commands::*;
|
||||
pub use hash_base64::HashBase64;
|
||||
pub use math_eval::SubCommand as MathEvalDeprecated;
|
||||
pub use source::Source;
|
||||
pub use str_datetime::StrDatetimeDeprecated;
|
||||
pub use str_decimal::StrDecimalDeprecated;
|
||||
|
Reference in New Issue
Block a user