From 9ba16dbdaf50db1fdbab0ec0976f1d82226343b4 Mon Sep 17 00:00:00 2001 From: 132ikl <132@ikl.sh> Date: Tue, 1 Apr 2025 08:17:36 -0400 Subject: [PATCH] Add boolean examples to `any` and `all` (#15442) # Description Follow-up to #15277 and #15392. Adds examples to `any` and `all` demonstrating using `any {}` or `all {}` with lists of booleans. We have a couple options that work for this use-case, but not sure which we should recommend. The PR currently uses (1). 1. `any {}` / `all {}` 2. `any { $in }` / `all { $in }` 3. `any { $in == true }` / `all { $in == true }` Would love to hear your thoughts on the above @fennewald @mtimaN @fdncred @NotTheDr01ds @ysthakur # User-Facing Changes * Added an extra example for `any` and `all` # Tests + Formatting N/A # After Submitting N/A --- crates/nu-command/src/filters/all.rs | 5 +++++ crates/nu-command/src/filters/any.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/crates/nu-command/src/filters/all.rs b/crates/nu-command/src/filters/all.rs index aa36118273..844d845a54 100644 --- a/crates/nu-command/src/filters/all.rs +++ b/crates/nu-command/src/filters/all.rs @@ -30,6 +30,11 @@ impl Command for All { fn examples(&self) -> Vec { vec![ + Example { + description: "Check if a list contains only true values", + example: "[false true true false] | all {}", + result: Some(Value::test_bool(false)), + }, Example { description: "Check if each row's status is the string 'UP'", example: "[[status]; [UP] [UP]] | all {|el| $el.status == UP }", diff --git a/crates/nu-command/src/filters/any.rs b/crates/nu-command/src/filters/any.rs index 230a96ebe7..3d6f5404a2 100644 --- a/crates/nu-command/src/filters/any.rs +++ b/crates/nu-command/src/filters/any.rs @@ -30,6 +30,11 @@ impl Command for Any { fn examples(&self) -> Vec { vec![ + Example { + description: "Check if a list contains any true values", + example: "[false true true false] | any {}", + result: Some(Value::test_bool(true)), + }, Example { description: "Check if any row's status is the string 'DOWN'", example: "[[status]; [UP] [DOWN] [UP]] | any {|el| $el.status == DOWN }",