cratification: part II of the math commands to nu-cmd-extra (#9657)

The following math commands are being moved to nu-cmd-extra

* cos
* cosh
* egamma
* phi
* pi
* sin
* sinh
* tan
* tanh
* tau

For now I think we have most of the obvious commands moved over based on

@sholderbach this should cover moving the "high school" commands..

>>Yeah I think this rough separation into "high school" math in extra
and "middle school"/"programmer" math in the core makes a ton of sense.

And to reference the @fdncred list from
https://github.com/nushell/nushell/pull/9647#issuecomment-1629498812
This commit is contained in:
Michael Angerman 2023-07-11 11:23:39 -07:00 committed by GitHub
parent e10d84b72f
commit 942c66a9f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 52 additions and 34 deletions

View File

@ -15,6 +15,7 @@ mod test_examples {
check_example_input_and_output_types_match_command_signature,
};
use crate::MathPi;
use nu_protocol::{
engine::{Command, EngineState, StateWorkingSet},
Type,
@ -63,6 +64,9 @@ 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(MathPi));
working_set.add_decl(Box::new(nu_command::MathRound));
// Adding the command that is being tested to the working set
working_set.add_decl(cmd);

View File

@ -1,3 +1,15 @@
mod cos;
mod cosh;
mod sin;
mod sinh;
mod tan;
mod tanh;
mod egamma;
mod phi;
mod pi;
mod tau;
mod arccos;
mod arccosh;
mod arcsin;
@ -5,6 +17,18 @@ mod arcsinh;
mod arctan;
mod arctanh;
pub use cos::SubCommand as MathCos;
pub use cosh::SubCommand as MathCosH;
pub use sin::SubCommand as MathSin;
pub use sinh::SubCommand as MathSinH;
pub use tan::SubCommand as MathTan;
pub use tanh::SubCommand as MathTanH;
pub use egamma::SubCommand as MathEulerGamma;
pub use phi::SubCommand as MathPhi;
pub use pi::SubCommand as MathPi;
pub use tau::SubCommand as MathTau;
pub use arccos::SubCommand as MathArcCos;
pub use arccosh::SubCommand as MathArcCosH;
pub use arcsin::SubCommand as MathArcSin;

View File

@ -31,6 +31,18 @@ pub use bits::BitsShl;
pub use bits::BitsShr;
pub use bits::BitsXor;
pub use math::MathCos;
pub use math::MathCosH;
pub use math::MathSin;
pub use math::MathSinH;
pub use math::MathTan;
pub use math::MathTanH;
pub use math::MathEulerGamma;
pub use math::MathPhi;
pub use math::MathPi;
pub use math::MathTau;
pub use math::MathArcCos;
pub use math::MathArcCosH;
pub use math::MathArcSin;
@ -113,7 +125,15 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState {
MathArcTan,
MathArcSinH,
MathArcCosH,
MathArcTanH
MathArcTanH,
MathSin,
MathCos,
MathTan,
MathSinH,
MathCosH,
MathTanH,
MathPi,
MathTau
};
working_set.render()

View File

@ -327,14 +327,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
MathStddev,
MathSum,
MathVariance,
MathSin,
MathCos,
MathTan,
MathSinH,
MathCosH,
MathTanH,
MathPi,
MathTau,
MathEuler,
MathExp,
MathLn,

View File

@ -9,9 +9,9 @@ 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, MathPi,
MathRound, ParEach, Path, PathParse, Random, Sort, SortBy, Split, SplitColumn, SplitRow,
Str, StrJoin, StrLength, StrReplace, Update, Url, Values, Wrap,
Ansi, Date, Enumerate, Flatten, From, Get, Into, IntoString, Math, MathEuler, MathRound,
ParEach, Path, PathParse, Random, Sort, SortBy, Split, SplitColumn, SplitRow, Str, StrJoin,
StrLength, StrReplace, Update, Url, Values, Wrap,
};
use crate::{Each, To};
use nu_cmd_lang::example_support::{
@ -80,7 +80,6 @@ mod test_examples {
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(MathPi));
working_set.add_decl(Box::new(MathRound));
working_set.add_decl(Box::new(Mut));
working_set.add_decl(Box::new(Path));

View File

@ -1,9 +1,6 @@
mod abs;
mod avg;
mod ceil;
mod cos;
mod cosh;
mod egamma;
mod euler;
mod exp;
mod floor;
@ -14,19 +11,12 @@ mod max;
mod median;
mod min;
mod mode;
mod phi;
mod pi;
mod product;
mod reducers;
mod round;
mod sin;
mod sinh;
mod sqrt;
mod stddev;
mod sum;
mod tan;
mod tanh;
mod tau;
mod utils;
mod variance;
@ -46,18 +36,7 @@ pub use stddev::SubCommand as MathStddev;
pub use sum::SubCommand as MathSum;
pub use variance::SubCommand as MathVariance;
pub use cos::SubCommand as MathCos;
pub use cosh::SubCommand as MathCosH;
pub use sin::SubCommand as MathSin;
pub use sinh::SubCommand as MathSinH;
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 phi::SubCommand as MathPhi;
pub use pi::SubCommand as MathPi;
pub use tau::SubCommand as MathTau;
pub use self::log::SubCommand as MathLog;
pub use exp::SubCommand as MathExp;