75lb / command-line-args

A mature, feature-complete library to parse command-line options.
MIT License
689 stars 106 forks source link

Support case insensitive command line options #116

Closed peazncheez closed 3 years ago

peazncheez commented 3 years ago

Adds a caseSensitive field to OptionDefinition to support parsing certain arguments in a case insensitive manner. The default behavior continues to treat all command line arguments as case sensitive.

The UNIX-based command line is traditionally case sensitive, but the Windows command line is not. I'm working on a Windows application and we're currently using this library, but we'd like our args to be parsed in a case-insensitive manner.

peazncheez commented 3 years ago

@75lb , mind reviewing / allowing the CI to run? And let me know if I shouldn't check in those dist files if they're generated at a later stage or something.

75lb commented 3 years ago

morning, thanks for the new feature - sounds good to me.. I will review it later today.. Yes, the dist should be checked in but don't worry about that - I'll take it from here as I might add some futher updates to freshen the library up..

peazncheez commented 3 years ago

hey @75lb , any updates? 🙂

75lb commented 3 years ago

Will you need the granularity of being able to set caseSensitive at the option level or can we set the flag once when invoking the parse function?? E.g.

commandLineArgs(optionDefinitions, { caseInsensitive: true })

Also, the general convention is to enable an option flag by setting it to true, not false, so I will probably change the option name to caseInsensitive..

75lb commented 3 years ago

Why are aliases always case-sensitive? Wouldn't it be more consistent to enable or disable case-sensitivity across the board?

peazncheez commented 3 years ago

Hey @75lb , thanks for the feedback. I had originally implemented the per-option case sensitivity granularity since that would be most flexible, but it's not necessary for my use case and I agree the additional complexity likely isn't worth it.

Pushed up some commits which:

75lb commented 3 years ago

Merged and released in v5.2.0, thanks. 👍

peazncheez commented 3 years ago

Awesome, thank you!