Argu
Argu copied to clipboard
Case insensitive matches for parameters
Description
Argu does not accept camel case command line parameters and it doesn't seem to be possible to enable case insensitive matches when parsing.
Repro steps
Run the following code snippet:
open Argu
type CliArguments =
| LogLevel of level: int
| Quit
interface IArgParserTemplate with
member s.Usage =
match s with
| LogLevel _ -> "set the log level."
| Quit -> "just quit."
let parser = ArgumentParser.Create<CliArguments>(programName = "test")
let res = parser.Parse [| "--loglevel"; "3" |] // works
let results = parser.Parse [| "--logLevel"; "3" |] // throws "Unhandled exception. Argu.ArguParseException: ERROR: unrecognized argument: '--logLevel'."
Expected behavior
Parser should accept both --loglevel and --logLevel or allow users to configure this behavior e.g. ArgumentParser.Create<CliArguments>(programName = "test", matchCase = false)
Actual behavior
The parser fails when provided with any command line parameter which is not lowercase.
Known workarounds
No workarounds.
Related information
- Operating system: Linux
- Branch: master
- .NET Runtime, CoreCLR or Mono Version: .NET 9
In general, AltCommandLine can be used to admit alernate capitalizations (and for something like a log level, you'd typically have a short alias like -L)
While your API proposal is not unreasonable, it is slightly at odds with the general unixy nature of the design:
- case sensitivity is definitely expected
- single char aliases can be stacked (i.e. -A -B can be supplied as
-AB) As a result, the main thing with case insensitivity (which IIRC was added relatively recently) is for matching the name of single case DU items.
Perhaps supporting an implicit camelCase variant for top level items is a recent meeting point? (ie. that would allow --logLevel OR --loglevel). Let me know what you think, but it feels like this is the least intrustive way to support your top level need (and remove a quirk I will admit I was also surprised by). Off the top of my head that should be a pretty small PR; will merge and release pretty quick if you'd be up for providing one?