From 6365ba0286fa6e8f5af3a30dc2014cd92e9c5fa1 Mon Sep 17 00:00:00 2001 From: Evan Platzer Date: Fri, 27 May 2022 10:38:54 -0400 Subject: [PATCH] Add search terms for `all?`, `any?`, `length`, and `keybindings` (#5665) * Add search terms for `all?` JavaScript has `Array.every` similar to `all?` * Add search terms for `any?` JavaScript has `Array.some` similar to `any?` * Add search terms for `length` Count, `len()`, and `size`/`sizeof` in widely-known programming languages are equivalent to `length` * Add search terms for `keybindings` Shortcut and hotkey are common synonyms (especially in web and GUI land) for keybindings. --- crates/nu-command/src/filters/all.rs | 4 ++++ crates/nu-command/src/filters/any.rs | 4 ++++ crates/nu-command/src/filters/length.rs | 4 ++++ .../nu-command/src/platform/reedline_commands/keybindings.rs | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/crates/nu-command/src/filters/all.rs b/crates/nu-command/src/filters/all.rs index f3f50c6736..ed81f74506 100644 --- a/crates/nu-command/src/filters/all.rs +++ b/crates/nu-command/src/filters/all.rs @@ -27,6 +27,10 @@ impl Command for All { "Test if every element of the input matches a predicate." } + fn search_terms(&self) -> Vec<&str> { + vec!["every"] + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/filters/any.rs b/crates/nu-command/src/filters/any.rs index 316fe069ec..bf30b59629 100644 --- a/crates/nu-command/src/filters/any.rs +++ b/crates/nu-command/src/filters/any.rs @@ -27,6 +27,10 @@ impl Command for Any { "Tests if any element of the input matches a predicate." } + fn search_terms(&self) -> Vec<&str> { + vec!["some"] + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/filters/length.rs b/crates/nu-command/src/filters/length.rs index 687459232c..bebafa1289 100644 --- a/crates/nu-command/src/filters/length.rs +++ b/crates/nu-command/src/filters/length.rs @@ -24,6 +24,10 @@ impl Command for Length { .category(Category::Filters) } + fn search_terms(&self) -> Vec<&str> { + vec!["count", "len", "size"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/platform/reedline_commands/keybindings.rs b/crates/nu-command/src/platform/reedline_commands/keybindings.rs index be5af78445..7cdfeddc77 100644 --- a/crates/nu-command/src/platform/reedline_commands/keybindings.rs +++ b/crates/nu-command/src/platform/reedline_commands/keybindings.rs @@ -21,6 +21,10 @@ impl Command for Keybindings { "Keybindings related commands" } + fn search_terms(&self) -> Vec<&str> { + vec!["shortcut", "hotkey"] + } + fn run( &self, engine_state: &EngineState,