Skip to content
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

Option not to reorder possible values for an argument #1549

Closed
rzumer opened this issue Sep 20, 2019 · 1 comment · Fixed by #3391
Closed

Option not to reorder possible values for an argument #1549

rzumer opened this issue Sep 20, 2019 · 1 comment · Fixed by #3391
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies E-easy Call for participation: Experience needed to fix: Easy / not much
Milestone

Comments

@rzumer
Copy link

rzumer commented Sep 20, 2019

Affected Version of clap

2.33.0

Bug or Feature Request Summary

I have a list of possible numeric values for a given argument, but clap reorders them in alphabetical (non-numeric) order.

Expected Behavior Summary

Being able to tell clap not to reorder my argument list.

Actual Behavior Summary

A list of numbers (e.g. ["0", "1", "2", "12"]) is reordered in non-numeric order (e.g. ["0", "1", "12", "2"]).

Sample Code or Link to Sample Code

let number_strings = ["0", "1", "2", "12"];

(boilerplate)
.arg(
    Arg::with_name("my_arg")
    .short("m")
    .long("my_arg")
    .value_name("MY_ARG")
    .possible_values(&number_strings)
)
(boilerplate)
Example Output

error: 'blah' isn't a valid value for '--my_arg <MY_ARG>'
[possible values: 0, 1, 12, 2]

@rzumer
Copy link
Author

rzumer commented Sep 27, 2019

Actually, it looks like --help displays options as ordered in the input list, but when passing an invalid argument value, the list of possible values displayed is reordered. So it is only an issue in the latter situation for me.

@CreepySkeleton CreepySkeleton added A-help Area: documentation, including docs.rs, readme, examples, etc... P4: nice to have C-enhancement Category: Raise on the bar on expectations labels Feb 1, 2020
@pksunkara pksunkara added this to the 3.1 milestone Apr 9, 2020
@epage epage added C-bug Category: Updating dependencies E-easy Call for participation: Experience needed to fix: Easy / not much and removed C-enhancement Category: Raise on the bar on expectations P4: nice to have labels Dec 9, 2021
epage added a commit to epage/clap that referenced this issue Feb 2, 2022
We respected it for `--help` but not error messages.

Fixes clap-rs#1549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants