From 88ec4186ec6355295464f3be5129106ee0592350 Mon Sep 17 00:00:00 2001 From: merelymyself <88221256+merelymyself@users.noreply.github.com> Date: Tue, 19 Apr 2022 05:33:32 +0800 Subject: [PATCH] Added search terms to math commands (#5224) --- crates/nu-command/src/math/abs.rs | 4 ++++ crates/nu-command/src/math/avg.rs | 4 ++++ crates/nu-command/src/math/ceil.rs | 4 ++++ crates/nu-command/src/math/eval.rs | 4 ++++ crates/nu-command/src/math/max.rs | 4 ++++ crates/nu-command/src/math/median.rs | 4 ++++ crates/nu-command/src/math/min.rs | 4 ++++ crates/nu-command/src/math/mode.rs | 4 ++++ crates/nu-command/src/math/product.rs | 4 ++++ crates/nu-command/src/math/round.rs | 4 ++++ crates/nu-command/src/math/sqrt.rs | 4 ++++ crates/nu-command/src/math/stddev.rs | 4 ++++ crates/nu-command/src/math/sum.rs | 4 ++++ 13 files changed, 52 insertions(+) diff --git a/crates/nu-command/src/math/abs.rs b/crates/nu-command/src/math/abs.rs index f75b280205..9cf131ce46 100644 --- a/crates/nu-command/src/math/abs.rs +++ b/crates/nu-command/src/math/abs.rs @@ -18,6 +18,10 @@ impl Command for SubCommand { "Returns absolute values of a list of numbers" } + fn search_terms(&self) -> Vec<&str> { + vec!["absolute", "modulus", "positive", "distance"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/math/avg.rs b/crates/nu-command/src/math/avg.rs index c2a2187eb5..08e221b89d 100644 --- a/crates/nu-command/src/math/avg.rs +++ b/crates/nu-command/src/math/avg.rs @@ -20,6 +20,10 @@ impl Command for SubCommand { "Finds the average of a list of numbers or tables" } + fn search_terms(&self) -> Vec<&str> { + vec!["average", "mean"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/math/ceil.rs b/crates/nu-command/src/math/ceil.rs index c21cd80e2e..7b87d97fac 100644 --- a/crates/nu-command/src/math/ceil.rs +++ b/crates/nu-command/src/math/ceil.rs @@ -18,6 +18,10 @@ impl Command for SubCommand { "Applies the ceil function to a list of numbers" } + fn search_terms(&self) -> Vec<&str> { + vec!["ceiling"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/math/eval.rs b/crates/nu-command/src/math/eval.rs index 8810599216..28bc02b56a 100644 --- a/crates/nu-command/src/math/eval.rs +++ b/crates/nu-command/src/math/eval.rs @@ -17,6 +17,10 @@ impl Command for SubCommand { "Evaluate a math expression into a number" } + fn search_terms(&self) -> Vec<&str> { + vec!["evaluation", "solve", "equation", "expression"] + } + fn signature(&self) -> Signature { Signature::build("math eval") .optional( diff --git a/crates/nu-command/src/math/max.rs b/crates/nu-command/src/math/max.rs index 2635192c57..afccd71f71 100644 --- a/crates/nu-command/src/math/max.rs +++ b/crates/nu-command/src/math/max.rs @@ -20,6 +20,10 @@ impl Command for SubCommand { "Finds the maximum within a list of numbers or tables" } + fn search_terms(&self) -> Vec<&str> { + vec!["maximum", "largest"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/math/median.rs b/crates/nu-command/src/math/median.rs index cae1499a8f..b2f40b27f3 100644 --- a/crates/nu-command/src/math/median.rs +++ b/crates/nu-command/src/math/median.rs @@ -22,6 +22,10 @@ impl Command for SubCommand { "Gets the median of a list of numbers" } + fn search_terms(&self) -> Vec<&str> { + vec!["middle", "average"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/math/min.rs b/crates/nu-command/src/math/min.rs index c897f4394b..1b637d86d4 100644 --- a/crates/nu-command/src/math/min.rs +++ b/crates/nu-command/src/math/min.rs @@ -20,6 +20,10 @@ impl Command for SubCommand { "Finds the minimum within a list of numbers or tables" } + fn search_terms(&self) -> Vec<&str> { + vec!["minimum", "smallest"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/math/mode.rs b/crates/nu-command/src/math/mode.rs index 4115a4f07b..7810ed9c32 100644 --- a/crates/nu-command/src/math/mode.rs +++ b/crates/nu-command/src/math/mode.rs @@ -43,6 +43,10 @@ impl Command for SubCommand { "Gets the most frequent element(s) from a list of numbers or tables" } + fn search_terms(&self) -> Vec<&str> { + vec!["common", "often", "average"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/math/product.rs b/crates/nu-command/src/math/product.rs index 563d991371..1fcfd197b2 100644 --- a/crates/nu-command/src/math/product.rs +++ b/crates/nu-command/src/math/product.rs @@ -20,6 +20,10 @@ impl Command for SubCommand { "Finds the product of a list of numbers or tables" } + fn search_terms(&self) -> Vec<&str> { + vec!["times", "multiply", "x", "*"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/math/round.rs b/crates/nu-command/src/math/round.rs index 8e21ae70c6..8f47e24253 100644 --- a/crates/nu-command/src/math/round.rs +++ b/crates/nu-command/src/math/round.rs @@ -28,6 +28,10 @@ impl Command for SubCommand { "Applies the round function to a list of numbers" } + fn search_terms(&self) -> Vec<&str> { + vec!["approx", "rough"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/math/sqrt.rs b/crates/nu-command/src/math/sqrt.rs index efc54cc0ff..2a38a76dc1 100644 --- a/crates/nu-command/src/math/sqrt.rs +++ b/crates/nu-command/src/math/sqrt.rs @@ -18,6 +18,10 @@ impl Command for SubCommand { "Applies the square root function to a list of numbers" } + fn search_terms(&self) -> Vec<&str> { + vec!["square", "root"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/math/stddev.rs b/crates/nu-command/src/math/stddev.rs index d7d370dd8a..cc10c1d2f5 100644 --- a/crates/nu-command/src/math/stddev.rs +++ b/crates/nu-command/src/math/stddev.rs @@ -22,6 +22,10 @@ impl Command for SubCommand { "Finds the stddev of a list of numbers or tables" } + fn search_terms(&self) -> Vec<&str> { + vec!["SD", "standard", "deviation", "dispersion", "variation"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/math/sum.rs b/crates/nu-command/src/math/sum.rs index 814856dec2..e341b099ec 100644 --- a/crates/nu-command/src/math/sum.rs +++ b/crates/nu-command/src/math/sum.rs @@ -20,6 +20,10 @@ impl Command for SubCommand { "Finds the sum of a list of numbers or tables" } + fn search_terms(&self) -> Vec<&str> { + vec!["plus", "add", "+"] + } + fn run( &self, _engine_state: &EngineState,