From 91e843a6d49eb9861238e0a8c3ec2c548d883704 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Fri, 13 Jun 2025 08:59:37 -0500 Subject: [PATCH] add `like`, `not-like` to `help operators` (#15959) # Description This PR adds `like` and `not-like` to the `help operators` command. Now it at least lists them. I wasn't sure if I should say `=~ or like` so I just separated them with a comma. ![image](https://github.com/user-attachments/assets/1165d900-80a2-4633-9b75-109fcb617c75) # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/help/help_operators.rs | 44 +++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/crates/nu-command/src/help/help_operators.rs b/crates/nu-command/src/help/help_operators.rs index eeea7ace67..4670b462e1 100644 --- a/crates/nu-command/src/help/help_operators.rs +++ b/crates/nu-command/src/help/help_operators.rs @@ -68,16 +68,40 @@ impl Command for HelpOperators { ] .into_iter() .map(|op| { - Value::record( - record! { - "type" => Value::string(op_type(&op), head), - "operator" => Value::string(op.to_string(), head), - "name" => Value::string(name(&op), head), - "description" => Value::string(description(&op), head), - "precedence" => Value::int(op.precedence().into(), head), - }, - head, - ) + if op == Operator::Comparison(Comparison::RegexMatch) { + Value::record( + record! { + "type" => Value::string(op_type(&op), head), + "operator" => Value::string("=~, like", head), + "name" => Value::string(name(&op), head), + "description" => Value::string(description(&op), head), + "precedence" => Value::int(op.precedence().into(), head), + }, + head, + ) + } else if op == Operator::Comparison(Comparison::NotRegexMatch) { + Value::record( + record! { + "type" => Value::string(op_type(&op), head), + "operator" => Value::string("!~, not-like", head), + "name" => Value::string(name(&op), head), + "description" => Value::string(description(&op), head), + "precedence" => Value::int(op.precedence().into(), head), + }, + head, + ) + } else { + Value::record( + record! { + "type" => Value::string(op_type(&op), head), + "operator" => Value::string(op.to_string(), head), + "name" => Value::string(name(&op), head), + "description" => Value::string(description(&op), head), + "precedence" => Value::int(op.precedence().into(), head), + }, + head, + ) + } }) .collect::>();