Repository navigation
random-list: fix dice and the error helper on current nushell #1301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||||||||||
| use std/random | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With this import, nu_scripts/modules/random-list/random-list.nu Lines 74 to 79 in 84629e8
|
||||||||||||||
|
|
||||||||||||||
| def throw-error [ | ||||||||||||||
| error: string | ||||||||||||||
| msg: string | ||||||||||||||
|
|
@@ -7,8 +9,7 @@ def throw-error [ | |||||||||||||
| msg: $"(ansi red_bold)($error)(ansi reset)" | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||
| label: { | ||||||||||||||
| text: $msg | ||||||||||||||
| start: $span.start | ||||||||||||||
| end: $span.end | ||||||||||||||
| span: $span | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guards only reject
< 0, so 0 gets through, and1..0counts down to[1, 0].random-list bool 0 | length,random-list uuid 0 | lengthandrandom-list dice 0 | lengthall return 2 on 0.116.2. Every subcommand uses the same1..$list_lengthloop (lines 29, 46, 60, 81, 95 and 108), and0..<$list_lengthgives 0 items for 0 and n items for n. The message "must be greater than 0" also says 0 is invalid while the check accepts it; "must not be negative" matches the check. This was already there before the PR, but the description says every subcommand returns what it should.nu_scripts/modules/random-list/random-list.nu
Lines 25 to 31 in 84629e8