From 54bc662e0e7ee519081a267bf4d2bb1b3f5189e7 Mon Sep 17 00:00:00 2001 From: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:17:42 +0200 Subject: [PATCH] Add long options for generators and math (#10752) --- crates/nu-cmd-extra/src/extra/math/arccos.rs | 2 +- crates/nu-cmd-extra/src/extra/math/arcsin.rs | 2 +- crates/nu-cmd-extra/src/extra/math/arctan.rs | 2 +- crates/nu-cmd-extra/src/extra/math/cos.rs | 2 +- crates/nu-cmd-extra/src/extra/math/tan.rs | 2 +- crates/nu-command/src/generators/seq_date.rs | 8 ++++---- crates/nu-command/src/math/round.rs | 4 ++-- crates/nu-command/src/math/stddev.rs | 2 +- crates/nu-command/src/math/variance.rs | 2 +- crates/nu-command/tests/commands/math/round.rs | 6 +++--- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/nu-cmd-extra/src/extra/math/arccos.rs b/crates/nu-cmd-extra/src/extra/math/arccos.rs index aa34ef0921..b1bdcf363f 100644 --- a/crates/nu-cmd-extra/src/extra/math/arccos.rs +++ b/crates/nu-cmd-extra/src/extra/math/arccos.rs @@ -60,7 +60,7 @@ impl Command for SubCommand { }, Example { description: "Get the arccosine of -1 in degrees", - example: "-1 | math arccos -d", + example: "-1 | math arccos --degrees", result: Some(Value::test_float(180.0)), }, ] diff --git a/crates/nu-cmd-extra/src/extra/math/arcsin.rs b/crates/nu-cmd-extra/src/extra/math/arcsin.rs index e99e3c5584..a9f943ded3 100644 --- a/crates/nu-cmd-extra/src/extra/math/arcsin.rs +++ b/crates/nu-cmd-extra/src/extra/math/arcsin.rs @@ -61,7 +61,7 @@ impl Command for SubCommand { }, Example { description: "Get the arcsine of 1 in degrees", - example: "1 | math arcsin -d", + example: "1 | math arcsin --degrees", result: Some(Value::test_float(90.0)), }, ] diff --git a/crates/nu-cmd-extra/src/extra/math/arctan.rs b/crates/nu-cmd-extra/src/extra/math/arctan.rs index cae303cab6..cca6bca71a 100644 --- a/crates/nu-cmd-extra/src/extra/math/arctan.rs +++ b/crates/nu-cmd-extra/src/extra/math/arctan.rs @@ -61,7 +61,7 @@ impl Command for SubCommand { }, Example { description: "Get the arctangent of -1 in degrees", - example: "-1 | math arctan -d", + example: "-1 | math arctan --degrees", result: Some(Value::test_float(-45.0)), }, ] diff --git a/crates/nu-cmd-extra/src/extra/math/cos.rs b/crates/nu-cmd-extra/src/extra/math/cos.rs index b9d6da10e4..2a45e6383b 100644 --- a/crates/nu-cmd-extra/src/extra/math/cos.rs +++ b/crates/nu-cmd-extra/src/extra/math/cos.rs @@ -59,7 +59,7 @@ impl Command for SubCommand { }, Example { description: "Apply the cosine to a list of angles in degrees", - example: "[0 90 180 270 360] | math cos -d", + example: "[0 90 180 270 360] | math cos --degrees", result: Some(Value::list( vec![ Value::test_float(1f64), diff --git a/crates/nu-cmd-extra/src/extra/math/tan.rs b/crates/nu-cmd-extra/src/extra/math/tan.rs index 0aad4376c9..b073ef831d 100644 --- a/crates/nu-cmd-extra/src/extra/math/tan.rs +++ b/crates/nu-cmd-extra/src/extra/math/tan.rs @@ -59,7 +59,7 @@ impl Command for SubCommand { }, Example { description: "Apply the tangent to a list of angles in degrees", - example: "[-45 0 45] | math tan -d", + example: "[-45 0 45] | math tan --degrees", result: Some(Value::list( vec![ Value::test_float(-1f64), diff --git a/crates/nu-command/src/generators/seq_date.rs b/crates/nu-command/src/generators/seq_date.rs index e9a6976a6a..83308e4903 100644 --- a/crates/nu-command/src/generators/seq_date.rs +++ b/crates/nu-command/src/generators/seq_date.rs @@ -67,17 +67,17 @@ impl Command for SeqDate { }, Example { description: "print the previous 10 days in YYYY-MM-DD format with newline separator", - example: "seq date --days 10 -r", + example: "seq date --days 10 --reverse", result: None, }, Example { description: "print the previous 10 days starting today in MM/DD/YYYY format with newline separator", - example: "seq date --days 10 -o '%m/%d/%Y' -r", + example: "seq date --days 10 -o '%m/%d/%Y' --reverse", result: None, }, Example { description: "print the first 10 days in January, 2020", - example: "seq date -b '2020-01-01' -e '2020-01-10'", + example: "seq date --begin-date '2020-01-01' --end-date '2020-01-10'", result: Some(Value::list( vec![ Value::test_string("2020-01-01"), @@ -96,7 +96,7 @@ impl Command for SeqDate { }, Example { description: "print every fifth day between January 1st 2020 and January 31st 2020", - example: "seq date -b '2020-01-01' -e '2020-01-31' -n 5", + example: "seq date --begin-date '2020-01-01' --end-date '2020-01-31' --increment 5", result: Some(Value::list( vec![ Value::test_string("2020-01-01"), diff --git a/crates/nu-command/src/math/round.rs b/crates/nu-command/src/math/round.rs index 8bf6600549..a86816c484 100644 --- a/crates/nu-command/src/math/round.rs +++ b/crates/nu-command/src/math/round.rs @@ -71,7 +71,7 @@ impl Command for SubCommand { }, Example { description: "Apply the round function with precision specified", - example: "[1.555 2.333 -3.111] | math round -p 2", + example: "[1.555 2.333 -3.111] | math round --precision 2", result: Some(Value::list( vec![ Value::test_float(1.56), @@ -83,7 +83,7 @@ impl Command for SubCommand { }, Example { description: "Apply negative precision to a list of numbers", - example: "[123, 123.3, -123.4] | math round -p -1", + example: "[123, 123.3, -123.4] | math round --precision -1", result: Some(Value::list( vec![ Value::test_int(120), diff --git a/crates/nu-command/src/math/stddev.rs b/crates/nu-command/src/math/stddev.rs index 623582ed07..0350a89334 100644 --- a/crates/nu-command/src/math/stddev.rs +++ b/crates/nu-command/src/math/stddev.rs @@ -58,7 +58,7 @@ impl Command for SubCommand { }, Example { description: "Compute the sample standard deviation of a list of numbers", - example: "[1 2 3 4 5] | math stddev -s", + example: "[1 2 3 4 5] | math stddev --sample", result: Some(Value::test_float(1.5811388300841898)), }, ] diff --git a/crates/nu-command/src/math/variance.rs b/crates/nu-command/src/math/variance.rs index 702a687bde..f28f7c60d1 100644 --- a/crates/nu-command/src/math/variance.rs +++ b/crates/nu-command/src/math/variance.rs @@ -50,7 +50,7 @@ impl Command for SubCommand { }, Example { description: "Get the sample variance of a list of numbers", - example: "[1 2 3 4 5] | math variance -s", + example: "[1 2 3 4 5] | math variance --sample", result: Some(Value::test_float(2.5)), }, ] diff --git a/crates/nu-command/tests/commands/math/round.rs b/crates/nu-command/tests/commands/math/round.rs index 5d2158a56f..b05bcf2d13 100644 --- a/crates/nu-command/tests/commands/math/round.rs +++ b/crates/nu-command/tests/commands/math/round.rs @@ -9,21 +9,21 @@ fn can_round_very_large_numbers() { #[test] fn can_round_very_large_numbers_with_precision() { - let actual = nu!("18.13725447800741422899276654867720121457878988 | math round -p 10"); + let actual = nu!("18.13725447800741422899276654867720121457878988 | math round --precision 10"); assert_eq!(actual.out, "18.137254478") } #[test] fn can_round_integer_with_negative_precision() { - let actual = nu!("123 | math round -p -1"); + let actual = nu!("123 | math round --precision -1"); assert_eq!(actual.out, "120") } #[test] fn can_round_float_with_negative_precision() { - let actual = nu!("123.3 | math round -p -1"); + let actual = nu!("123.3 | math round --precision -1"); assert_eq!(actual.out, "120") }