From 3c583c9a209dd2eccb41313cd42315cb0508f98a Mon Sep 17 00:00:00 2001 From: Michael Angerman <1809991+stormasm@users.noreply.github.com> Date: Thu, 13 Jul 2023 09:11:26 -0700 Subject: [PATCH] cratification: part III of the math commands to nu-cmd-extra (#9674) The following math commands are being moved to nu-cmd-extra * e (euler) * exp * ln This should conclude moving the extra math commands as discussed in yesterday's core team meeting... The remaining math commands will stay in nu-command (for now).... --- crates/nu-cmd-extra/src/example_test.rs | 2 ++ .../src => nu-cmd-extra/src/extra}/math/euler.rs | 0 .../src => nu-cmd-extra/src/extra}/math/exp.rs | 0 .../{nu-command/src => nu-cmd-extra/src/extra}/math/ln.rs | 0 crates/nu-cmd-extra/src/extra/math/mod.rs | 6 ++++++ crates/nu-cmd-extra/src/extra/mod.rs | 8 +++++++- crates/nu-command/src/default_context.rs | 3 --- crates/nu-command/src/example_test.rs | 5 ++--- crates/nu-command/src/math/mod.rs | 7 ------- 9 files changed, 17 insertions(+), 14 deletions(-) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/euler.rs (100%) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/exp.rs (100%) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/ln.rs (100%) diff --git a/crates/nu-cmd-extra/src/example_test.rs b/crates/nu-cmd-extra/src/example_test.rs index 9c352b108a..af353520ca 100644 --- a/crates/nu-cmd-extra/src/example_test.rs +++ b/crates/nu-cmd-extra/src/example_test.rs @@ -15,6 +15,7 @@ mod test_examples { check_example_input_and_output_types_match_command_signature, }; + use crate::MathEuler; use crate::MathPi; use nu_protocol::{ engine::{Command, EngineState, StateWorkingSet}, @@ -65,6 +66,7 @@ mod test_examples { working_set.add_decl(Box::new(nu_command::Enumerate)); working_set.add_decl(Box::new(nu_cmd_lang::If)); // math commands + working_set.add_decl(Box::new(MathEuler)); working_set.add_decl(Box::new(MathPi)); working_set.add_decl(Box::new(nu_command::MathRound)); diff --git a/crates/nu-command/src/math/euler.rs b/crates/nu-cmd-extra/src/extra/math/euler.rs similarity index 100% rename from crates/nu-command/src/math/euler.rs rename to crates/nu-cmd-extra/src/extra/math/euler.rs diff --git a/crates/nu-command/src/math/exp.rs b/crates/nu-cmd-extra/src/extra/math/exp.rs similarity index 100% rename from crates/nu-command/src/math/exp.rs rename to crates/nu-cmd-extra/src/extra/math/exp.rs diff --git a/crates/nu-command/src/math/ln.rs b/crates/nu-cmd-extra/src/extra/math/ln.rs similarity index 100% rename from crates/nu-command/src/math/ln.rs rename to crates/nu-cmd-extra/src/extra/math/ln.rs diff --git a/crates/nu-cmd-extra/src/extra/math/mod.rs b/crates/nu-cmd-extra/src/extra/math/mod.rs index d2a02de1ab..35e2fcc20d 100644 --- a/crates/nu-cmd-extra/src/extra/math/mod.rs +++ b/crates/nu-cmd-extra/src/extra/math/mod.rs @@ -6,6 +6,9 @@ mod tan; mod tanh; mod egamma; +mod euler; +mod exp; +mod ln; mod phi; mod pi; mod tau; @@ -25,6 +28,9 @@ pub use tan::SubCommand as MathTan; pub use tanh::SubCommand as MathTanH; pub use egamma::SubCommand as MathEulerGamma; +pub use euler::SubCommand as MathEuler; +pub use exp::SubCommand as MathExp; +pub use ln::SubCommand as MathLn; pub use phi::SubCommand as MathPhi; pub use pi::SubCommand as MathPi; pub use tau::SubCommand as MathTau; diff --git a/crates/nu-cmd-extra/src/extra/mod.rs b/crates/nu-cmd-extra/src/extra/mod.rs index e3c6dbaeff..009eb16805 100644 --- a/crates/nu-cmd-extra/src/extra/mod.rs +++ b/crates/nu-cmd-extra/src/extra/mod.rs @@ -38,7 +38,10 @@ pub use math::MathSinH; pub use math::MathTan; pub use math::MathTanH; +pub use math::MathEuler; pub use math::MathEulerGamma; +pub use math::MathExp; +pub use math::MathLn; pub use math::MathPhi; pub use math::MathPi; pub use math::MathTau; @@ -133,7 +136,10 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState { MathCosH, MathTanH, MathPi, - MathTau + MathTau, + MathEuler, + MathExp, + MathLn }; working_set.render() diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 23c3538bb4..66b64137dc 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -327,9 +327,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { MathStddev, MathSum, MathVariance, - MathEuler, - MathExp, - MathLn, MathLog, }; diff --git a/crates/nu-command/src/example_test.rs b/crates/nu-command/src/example_test.rs index dc74d62a3b..121ee76790 100644 --- a/crates/nu-command/src/example_test.rs +++ b/crates/nu-command/src/example_test.rs @@ -9,8 +9,8 @@ pub fn test_examples(cmd: impl Command + 'static) { #[cfg(test)] mod test_examples { use super::super::{ - Ansi, Date, Enumerate, Flatten, From, Get, Into, IntoString, Math, MathEuler, MathRound, - ParEach, Path, PathParse, Random, Sort, SortBy, Split, SplitColumn, SplitRow, Str, StrJoin, + Ansi, Date, Enumerate, Flatten, From, Get, Into, IntoString, Math, MathRound, ParEach, + Path, PathParse, Random, Sort, SortBy, Split, SplitColumn, SplitRow, Str, StrJoin, StrLength, StrReplace, Update, Url, Values, Wrap, }; use crate::{Each, To}; @@ -79,7 +79,6 @@ mod test_examples { working_set.add_decl(Box::new(IntoString)); working_set.add_decl(Box::new(Let)); working_set.add_decl(Box::new(Math)); - working_set.add_decl(Box::new(MathEuler)); working_set.add_decl(Box::new(MathRound)); working_set.add_decl(Box::new(Mut)); working_set.add_decl(Box::new(Path)); diff --git a/crates/nu-command/src/math/mod.rs b/crates/nu-command/src/math/mod.rs index 80d102cf4d..97828c8b86 100644 --- a/crates/nu-command/src/math/mod.rs +++ b/crates/nu-command/src/math/mod.rs @@ -1,10 +1,7 @@ mod abs; mod avg; mod ceil; -mod euler; -mod exp; mod floor; -mod ln; mod log; pub mod math_; mod max; @@ -36,8 +33,4 @@ pub use stddev::SubCommand as MathStddev; pub use sum::SubCommand as MathSum; pub use variance::SubCommand as MathVariance; -pub use euler::SubCommand as MathEuler; - pub use self::log::SubCommand as MathLog; -pub use exp::SubCommand as MathExp; -pub use ln::SubCommand as MathLn;