mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 17:34:00 +01:00
Clarify random int
help (#13503)
# Description Minor nitpicks, but the `random int` help and examples were a bit ambiguous in several aspects. Updated to clarify that: * An unconstrained `random int` returns a non-negative integer. That is, the smallest potential value is 0. Technically integers include negative numbers as well, and `random int` will never return one unless you pass it a range with a negative lower-bound. * To that end, changed the final example to demonstrate a negative lower-bound. * The range is inclusive. While most people would probably assume this, the changes make this explicit in the examples and argument description. # User-Facing Changes Help only # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib # After Submitting N/A
This commit is contained in:
parent
42531e017c
commit
3dc9691aaa
@ -15,7 +15,11 @@ impl Command for SubCommand {
|
|||||||
Signature::build("random int")
|
Signature::build("random int")
|
||||||
.input_output_types(vec![(Type::Nothing, Type::Int)])
|
.input_output_types(vec![(Type::Nothing, Type::Int)])
|
||||||
.allow_variants_without_examples(true)
|
.allow_variants_without_examples(true)
|
||||||
.optional("range", SyntaxShape::Range, "Range of values.")
|
.optional(
|
||||||
|
"range",
|
||||||
|
SyntaxShape::Range,
|
||||||
|
"Range of potential values, inclusive of both start and end values.",
|
||||||
|
)
|
||||||
.category(Category::Random)
|
.category(Category::Random)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,12 +44,12 @@ impl Command for SubCommand {
|
|||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "Generate an unconstrained random integer",
|
description: "Generate a non-negative random integer",
|
||||||
example: "random int",
|
example: "random int",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Generate a random integer less than or equal to 500",
|
description: "Generate a random integer between 0 (inclusive) and 500 (inclusive)",
|
||||||
example: "random int ..500",
|
example: "random int ..500",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
@ -55,8 +59,8 @@ impl Command for SubCommand {
|
|||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Generate a random integer between 1 and 10",
|
description: "Generate a random integer between -10 (inclusive) and 10 (inclusive)",
|
||||||
example: "random int 1..10",
|
example: "random int (-10)..10",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user