From 667eb27d1bba4c0aea9d76d53c74ece1c7b519ed Mon Sep 17 00:00:00 2001 From: Abdulqudduus Babalola Date: Sat, 23 Apr 2022 14:54:03 +0100 Subject: [PATCH] feat: add search terms to date (#5306) * add search terms * add search terms * add search terms * add search terms * add search terms * add search terms * add search terms * add search terms * add search patterns * run cargo fmt --all --- crates/nu-command/src/date/date_.rs | 14 ++++++++++++++ crates/nu-command/src/date/format.rs | 4 ++++ crates/nu-command/src/date/humanize.rs | 15 +++++++++++++++ crates/nu-command/src/date/list_timezone.rs | 4 ++++ crates/nu-command/src/date/now.rs | 4 ++++ crates/nu-command/src/date/to_record.rs | 4 ++++ crates/nu-command/src/date/to_table.rs | 4 ++++ crates/nu-command/src/date/to_timezone.rs | 14 ++++++++++++++ crates/nu-command/src/filesystem/cd.rs | 4 ++++ crates/nu-command/src/filesystem/cp.rs | 4 ++++ crates/nu-command/src/filesystem/glob.rs | 4 ++++ crates/nu-command/src/filesystem/mkdir.rs | 12 ++++++++++++ crates/nu-command/src/filesystem/mv.rs | 4 ++++ crates/nu-command/src/filesystem/open.rs | 4 ++++ crates/nu-command/src/filesystem/rm.rs | 4 ++++ crates/nu-command/src/filesystem/save.rs | 4 ++++ crates/nu-command/src/filesystem/touch.rs | 4 ++++ 17 files changed, 107 insertions(+) diff --git a/crates/nu-command/src/date/date_.rs b/crates/nu-command/src/date/date_.rs index 88151d2d99..a3943a4fc7 100644 --- a/crates/nu-command/src/date/date_.rs +++ b/crates/nu-command/src/date/date_.rs @@ -21,6 +21,20 @@ impl Command for Date { "Date-related commands" } + fn search_terms(&self) -> Vec<&str> { + vec![ + "date", + "time", + "now", + "today", + "tomorrow", + "yesterday", + "weekday", + "weekday_name", + "timezone", + ] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/date/format.rs b/crates/nu-command/src/date/format.rs index 2ce4624343..833eae133b 100644 --- a/crates/nu-command/src/date/format.rs +++ b/crates/nu-command/src/date/format.rs @@ -31,6 +31,10 @@ impl Command for SubCommand { "Format a given date using a format string." } + fn search_terms(&self) -> Vec<&str> { + vec!["date", "format", "strftime"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/date/humanize.rs b/crates/nu-command/src/date/humanize.rs index df8db8e5c3..8b20eff084 100644 --- a/crates/nu-command/src/date/humanize.rs +++ b/crates/nu-command/src/date/humanize.rs @@ -20,6 +20,21 @@ impl Command for SubCommand { "Print a 'humanized' format for the date, relative to now." } + fn search_terms(&self) -> Vec<&str> { + vec![ + "date", + "humanize", + "relative", + "now", + "today", + "tomorrow", + "yesterday", + "weekday", + "weekday_name", + "timezone", + ] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/date/list_timezone.rs b/crates/nu-command/src/date/list_timezone.rs index 2d9b0373e8..bdf3beab3b 100644 --- a/crates/nu-command/src/date/list_timezone.rs +++ b/crates/nu-command/src/date/list_timezone.rs @@ -21,6 +21,10 @@ impl Command for SubCommand { "List supported time zones." } + fn search_terms(&self) -> Vec<&str> { + vec!["UTC", "GMT", "timezone", "list", "list-timezone"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/date/now.rs b/crates/nu-command/src/date/now.rs index d53cc4e6df..4efbdff08d 100644 --- a/crates/nu-command/src/date/now.rs +++ b/crates/nu-command/src/date/now.rs @@ -18,6 +18,10 @@ impl Command for SubCommand { "Get the current date." } + fn search_terms(&self) -> Vec<&str> { + vec!["date", "now", "present", "current-time"] + } + fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/date/to_record.rs b/crates/nu-command/src/date/to_record.rs index 3d1a637d89..e43790e1b0 100644 --- a/crates/nu-command/src/date/to_record.rs +++ b/crates/nu-command/src/date/to_record.rs @@ -22,6 +22,10 @@ impl Command for SubCommand { "Convert the date into a structured table." } + fn search_terms(&self) -> Vec<&str> { + vec!["date", "to", "record", "structured", "table"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/date/to_table.rs b/crates/nu-command/src/date/to_table.rs index 54a0236835..dd84bf33b3 100644 --- a/crates/nu-command/src/date/to_table.rs +++ b/crates/nu-command/src/date/to_table.rs @@ -22,6 +22,10 @@ impl Command for SubCommand { "Convert the date into a structured table." } + fn search_terms(&self) -> Vec<&str> { + vec!["date", "to", "record", "structured", "table"] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/date/to_timezone.rs b/crates/nu-command/src/date/to_timezone.rs index 966088a28c..82c1324675 100644 --- a/crates/nu-command/src/date/to_timezone.rs +++ b/crates/nu-command/src/date/to_timezone.rs @@ -32,6 +32,20 @@ impl Command for SubCommand { "Use 'date list-timezone' to list all supported time zones." } + fn search_terms(&self) -> Vec<&str> { + vec![ + "date", + "to", + "timezone", + "transform", + "convert", + "UTC", + "GMT", + "list", + "list-timezone", + ] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/filesystem/cd.rs b/crates/nu-command/src/filesystem/cd.rs index 4ca4a9dbbc..f129509fde 100644 --- a/crates/nu-command/src/filesystem/cd.rs +++ b/crates/nu-command/src/filesystem/cd.rs @@ -17,6 +17,10 @@ impl Command for Cd { "Change directory." } + fn search_terms(&self) -> Vec<&str> { + vec!["cd", "change", "directory", "dir", "folder", "switch"] + } + fn signature(&self) -> nu_protocol::Signature { Signature::build("cd") .optional("path", SyntaxShape::Directory, "the path to change to") diff --git a/crates/nu-command/src/filesystem/cp.rs b/crates/nu-command/src/filesystem/cp.rs index 4600f885b8..43f505a4f2 100644 --- a/crates/nu-command/src/filesystem/cp.rs +++ b/crates/nu-command/src/filesystem/cp.rs @@ -28,6 +28,10 @@ impl Command for Cp { "Copy files." } + fn search_terms(&self) -> Vec<&str> { + vec!["cp", "copy", "file", "files"] + } + fn signature(&self) -> Signature { Signature::build("cp") .required("source", SyntaxShape::GlobPattern, "the place to copy from") diff --git a/crates/nu-command/src/filesystem/glob.rs b/crates/nu-command/src/filesystem/glob.rs index 8e061a69ef..981981c949 100644 --- a/crates/nu-command/src/filesystem/glob.rs +++ b/crates/nu-command/src/filesystem/glob.rs @@ -32,6 +32,10 @@ impl Command for Glob { "Creates a list of files and/or folders based on the glob pattern provided." } + fn search_terms(&self) -> Vec<&str> { + vec!["glob", "files", "folders", "list", "ls"] + } + fn examples(&self) -> Vec { vec![ Example { diff --git a/crates/nu-command/src/filesystem/mkdir.rs b/crates/nu-command/src/filesystem/mkdir.rs index cfbe72b993..b08cfd31f4 100644 --- a/crates/nu-command/src/filesystem/mkdir.rs +++ b/crates/nu-command/src/filesystem/mkdir.rs @@ -32,6 +32,18 @@ impl Command for Mkdir { "Make directories, creates intermediary directories as required." } + fn search_terms(&self) -> Vec<&str> { + vec![ + "mkdir", + "make", + "directory", + "dir", + "folder", + "make_dir", + "make_dirs", + ] + } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/filesystem/mv.rs b/crates/nu-command/src/filesystem/mv.rs index a00efb01c7..f5e8a0cf64 100644 --- a/crates/nu-command/src/filesystem/mv.rs +++ b/crates/nu-command/src/filesystem/mv.rs @@ -29,6 +29,10 @@ impl Command for Mv { "Move files or directories." } + fn search_terms(&self) -> Vec<&str> { + vec!["mv", "move"] + } + fn signature(&self) -> nu_protocol::Signature { Signature::build("mv") .required( diff --git a/crates/nu-command/src/filesystem/open.rs b/crates/nu-command/src/filesystem/open.rs index 874c5d2f76..57792c0be2 100644 --- a/crates/nu-command/src/filesystem/open.rs +++ b/crates/nu-command/src/filesystem/open.rs @@ -25,6 +25,10 @@ impl Command for Open { "Load a file into a cell, converting to table if possible (avoid by appending '--raw')." } + fn search_terms(&self) -> Vec<&str> { + vec!["open", "load", "read", "load_file", "read_file"] + } + fn signature(&self) -> nu_protocol::Signature { Signature::build("open") .optional("filename", SyntaxShape::Filepath, "the filename to use") diff --git a/crates/nu-command/src/filesystem/rm.rs b/crates/nu-command/src/filesystem/rm.rs index edebc6f25d..8cc7cb3d73 100644 --- a/crates/nu-command/src/filesystem/rm.rs +++ b/crates/nu-command/src/filesystem/rm.rs @@ -38,6 +38,10 @@ impl Command for Rm { "Remove file(s)." } + fn search_terms(&self) -> Vec<&str> { + vec!["rm", "remove"] + } + fn signature(&self) -> Signature { let sig = Signature::build("rm"); #[cfg(all( diff --git a/crates/nu-command/src/filesystem/save.rs b/crates/nu-command/src/filesystem/save.rs index d854a39680..8f71c095de 100644 --- a/crates/nu-command/src/filesystem/save.rs +++ b/crates/nu-command/src/filesystem/save.rs @@ -20,6 +20,10 @@ impl Command for Save { "Save a file." } + fn search_terms(&self) -> Vec<&str> { + vec!["save", "write", "write_file"] + } + fn signature(&self) -> nu_protocol::Signature { Signature::build("save") .required("filename", SyntaxShape::Filepath, "the filename to use") diff --git a/crates/nu-command/src/filesystem/touch.rs b/crates/nu-command/src/filesystem/touch.rs index 8f3e755595..485c2bc5f9 100644 --- a/crates/nu-command/src/filesystem/touch.rs +++ b/crates/nu-command/src/filesystem/touch.rs @@ -24,6 +24,10 @@ impl Command for Touch { "touch" } + fn search_terms(&self) -> Vec<&str> { + vec!["touch"] + } + fn signature(&self) -> Signature { Signature::build("touch") .required(