From d704b05b7a2b6c2923e68eaf8fecd6a454af1950 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sun, 18 Sep 2022 11:24:27 -0400 Subject: [PATCH] Improve uniq documentation (#6580) --- crates/nu-command/src/filters/uniq.rs | 28 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/crates/nu-command/src/filters/uniq.rs b/crates/nu-command/src/filters/uniq.rs index 7c519032c..f64e3b7f3 100644 --- a/crates/nu-command/src/filters/uniq.rs +++ b/crates/nu-command/src/filters/uniq.rs @@ -14,23 +14,31 @@ impl Command for Uniq { fn signature(&self) -> Signature { Signature::build("uniq") - .switch("count", "Count the unique rows", Some('c')) + .switch( + "count", + "Return a table containing the distinct input values together with their counts", + Some('c'), + ) .switch( "repeated", - "Count the rows that has more than one value", + "Return the input values that occur more than once", Some('d'), ) .switch( "ignore-case", - "Ignore differences in case when comparing", + "Ignore differences in case when comparing input values", Some('i'), ) - .switch("unique", "Only return unique values", Some('u')) + .switch( + "unique", + "Return the input values that occur once only", + Some('u'), + ) .category(Category::Filters) } fn usage(&self) -> &str { - "Return the unique rows." + "Return the distinct values in the input." } fn search_terms(&self) -> Vec<&str> { @@ -50,7 +58,7 @@ impl Command for Uniq { fn examples(&self) -> Vec { vec![ Example { - description: "Remove duplicate rows of a list/table", + description: "Return the distinct values of a list/table (remove duplicates so that each value occurs once only)", example: "[2 3 3 4] | uniq", result: Some(Value::List { vals: vec![Value::test_int(2), Value::test_int(3), Value::test_int(4)], @@ -58,7 +66,7 @@ impl Command for Uniq { }), }, Example { - description: "Only print duplicate lines, one for each group", + description: "Return the input values that occur more than once", example: "[1 2 2] | uniq -d", result: Some(Value::List { vals: vec![Value::test_int(2)], @@ -66,7 +74,7 @@ impl Command for Uniq { }), }, Example { - description: "Only print unique lines lines", + description: "Return the input values that occur once only", example: "[1 2 2] | uniq -u", result: Some(Value::List { vals: vec![Value::test_int(1)], @@ -74,7 +82,7 @@ impl Command for Uniq { }), }, Example { - description: "Ignore differences in case when comparing", + description: "Ignore differences in case when comparing input values", example: "['hello' 'goodbye' 'Hello'] | uniq -i", result: Some(Value::List { vals: vec![Value::test_string("hello"), Value::test_string("goodbye")], @@ -82,7 +90,7 @@ impl Command for Uniq { }), }, Example { - description: "Remove duplicate rows and show counts of a list/table", + description: "Return a table containing the distinct input values together with their counts", example: "[1 2 2] | uniq -c", result: Some(Value::List { vals: vec![