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

Provide ability to 'opt into' case insensitive option/argument names #4977

Open
2 tasks done
jerrywrice opened this issue Jun 19, 2023 · 3 comments
Open
2 tasks done
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@jerrywrice
Copy link

Please complete the following tasks

Clap Version

3.1.6

Describe your use case

It would be beneficial for a new version of clap to provide a means which permits any command line argument name (for example '--PORT=dev1') to be matched in a case insensitive manner. Currently the run-time parser displays an error message indicating it found an unexpected argument (whereas a case-insensitive compare would in-fact match). The idea that fifty years ago the Unix folks chose that command line argument names should be case sensitive is irrelevant, since newly developed applications would need to 'opt into' this as it wouldn't be the default.

Describe the solution you'd like

Adding a new setter method 'ignore_name_case(bool)' to clap::builder::Command' seems fine.

.

Alternatives, if applicable

No response

Additional Context

No response

@jerrywrice jerrywrice added the C-enhancement Category: Raise on the bar on expectations label Jun 19, 2023
@epage
Copy link
Member

epage commented Jun 20, 2023

What isn't clear from this is "why".

What value is this providing end-users? Under what situations is someone typing --PORT rather than --port? For example, in #4955 someone requested case insensitivity but the actual relevant user patterns for them were finite and they were better served by explicitly listing the situations with aliases.

I'd also recommend making a case by looking for prior art. Are there well received CLIs that accept case insensitive flags and subcommands? Are there major parsers that support it?

@jerrywrice
Copy link
Author

jerrywrice commented Jun 20, 2023

'Why' ... so that a user of an application with utilizes the 'clap' crate isn't forced to edit and reenter their application command line due to mistyping an command line argument (switch) name which differs only in its character case. Note that Windows application often have command line arguments which allow case-insensivity with the switch prefixes (names). Check out the 'Dir' command for instance (and its options).

@epage
Copy link
Member

epage commented Jun 20, 2023

For straight typos on a US standard keyboard, shift is likely to be accidentally be hit when typing a flag or a command name.

For people assuming the wrong case, with the convention being for lower case, docs being in lower case, and (optional completions) helping towards lower case, it is unclear to me how someone would run into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants