From e10d84b72fedf1f5d44baeeb353fe27b48633c00 Mon Sep 17 00:00:00 2001 From: Michael Angerman <1809991+stormasm@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:08:45 -0700 Subject: [PATCH] cratification: start moving over the math commands to nu-cmd-extra (#9647) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * arccos * arccosh * arcsin * arcsinh * arctan * arctanh The above commands are being ported over to nu-cmd-extra I initially moved all of the math commands over but there are some issues with the tests... So we will move them over slowly --- and actually I kind of like this idea better... Because some of the math commands we might want to leave in the core nushell... Stay tuned... For more details 👍 Read this document: https://github.com/stormasm/nutmp/blob/main/commands/math.md --- .../src/extra}/math/arccos.rs | 0 .../src/extra}/math/arccosh.rs | 0 .../src/extra}/math/arcsin.rs | 0 .../src/extra}/math/arcsinh.rs | 0 .../src/extra}/math/arctan.rs | 0 .../src/extra}/math/arctanh.rs | 0 crates/nu-cmd-extra/src/extra/math/mod.rs | 13 +++++++++++++ crates/nu-cmd-extra/src/extra/mod.rs | 18 ++++++++++++++++++ crates/nu-command/src/default_context.rs | 6 ------ crates/nu-command/src/math/mod.rs | 13 ------------- 10 files changed, 31 insertions(+), 19 deletions(-) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/arccos.rs (100%) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/arccosh.rs (100%) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/arcsin.rs (100%) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/arcsinh.rs (100%) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/arctan.rs (100%) rename crates/{nu-command/src => nu-cmd-extra/src/extra}/math/arctanh.rs (100%) create mode 100644 crates/nu-cmd-extra/src/extra/math/mod.rs diff --git a/crates/nu-command/src/math/arccos.rs b/crates/nu-cmd-extra/src/extra/math/arccos.rs similarity index 100% rename from crates/nu-command/src/math/arccos.rs rename to crates/nu-cmd-extra/src/extra/math/arccos.rs diff --git a/crates/nu-command/src/math/arccosh.rs b/crates/nu-cmd-extra/src/extra/math/arccosh.rs similarity index 100% rename from crates/nu-command/src/math/arccosh.rs rename to crates/nu-cmd-extra/src/extra/math/arccosh.rs diff --git a/crates/nu-command/src/math/arcsin.rs b/crates/nu-cmd-extra/src/extra/math/arcsin.rs similarity index 100% rename from crates/nu-command/src/math/arcsin.rs rename to crates/nu-cmd-extra/src/extra/math/arcsin.rs diff --git a/crates/nu-command/src/math/arcsinh.rs b/crates/nu-cmd-extra/src/extra/math/arcsinh.rs similarity index 100% rename from crates/nu-command/src/math/arcsinh.rs rename to crates/nu-cmd-extra/src/extra/math/arcsinh.rs diff --git a/crates/nu-command/src/math/arctan.rs b/crates/nu-cmd-extra/src/extra/math/arctan.rs similarity index 100% rename from crates/nu-command/src/math/arctan.rs rename to crates/nu-cmd-extra/src/extra/math/arctan.rs diff --git a/crates/nu-command/src/math/arctanh.rs b/crates/nu-cmd-extra/src/extra/math/arctanh.rs similarity index 100% rename from crates/nu-command/src/math/arctanh.rs rename to crates/nu-cmd-extra/src/extra/math/arctanh.rs diff --git a/crates/nu-cmd-extra/src/extra/math/mod.rs b/crates/nu-cmd-extra/src/extra/math/mod.rs new file mode 100644 index 0000000000..411f899898 --- /dev/null +++ b/crates/nu-cmd-extra/src/extra/math/mod.rs @@ -0,0 +1,13 @@ +mod arccos; +mod arccosh; +mod arcsin; +mod arcsinh; +mod arctan; +mod arctanh; + +pub use arccos::SubCommand as MathArcCos; +pub use arccosh::SubCommand as MathArcCosH; +pub use arcsin::SubCommand as MathArcSin; +pub use arcsinh::SubCommand as MathArcSinH; +pub use arctan::SubCommand as MathArcTan; +pub use arctanh::SubCommand as MathArcTanH; diff --git a/crates/nu-cmd-extra/src/extra/mod.rs b/crates/nu-cmd-extra/src/extra/mod.rs index ccf9409b8c..8f77bf7dd3 100644 --- a/crates/nu-cmd-extra/src/extra/mod.rs +++ b/crates/nu-cmd-extra/src/extra/mod.rs @@ -3,6 +3,7 @@ mod bytes; mod conversions; mod filters; mod formats; +mod math; mod platform; mod strings; @@ -30,6 +31,13 @@ pub use bits::BitsShl; pub use bits::BitsShr; pub use bits::BitsXor; +pub use math::MathArcCos; +pub use math::MathArcCosH; +pub use math::MathArcSin; +pub use math::MathArcSinH; +pub use math::MathArcTan; +pub use math::MathArcTanH; + use nu_protocol::engine::{EngineState, StateWorkingSet}; pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState { @@ -98,6 +106,16 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState { BytesBuild } + // Math + bind_command! { + MathArcSin, + MathArcCos, + MathArcTan, + MathArcSinH, + MathArcCosH, + MathArcTanH + }; + working_set.render() }; diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 771b945e97..86477dad2e 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -333,12 +333,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { MathSinH, MathCosH, MathTanH, - MathArcSin, - MathArcCos, - MathArcTan, - MathArcSinH, - MathArcCosH, - MathArcTanH, MathPi, MathTau, MathEuler, diff --git a/crates/nu-command/src/math/mod.rs b/crates/nu-command/src/math/mod.rs index b602daee99..520ee6d821 100644 --- a/crates/nu-command/src/math/mod.rs +++ b/crates/nu-command/src/math/mod.rs @@ -1,10 +1,4 @@ mod abs; -mod arccos; -mod arccosh; -mod arcsin; -mod arcsinh; -mod arctan; -mod arctanh; mod avg; mod ceil; mod cos; @@ -59,13 +53,6 @@ pub use sinh::SubCommand as MathSinH; pub use tan::SubCommand as MathTan; pub use tanh::SubCommand as MathTanH; -pub use arccos::SubCommand as MathArcCos; -pub use arccosh::SubCommand as MathArcCosH; -pub use arcsin::SubCommand as MathArcSin; -pub use arcsinh::SubCommand as MathArcSinH; -pub use arctan::SubCommand as MathArcTan; -pub use arctanh::SubCommand as MathArcTanH; - pub use egamma::SubCommand as MathEulerGamma; pub use euler::SubCommand as MathEuler; pub use phi::SubCommand as MathPhi;