apple / swift-argument-parser

Straightforward, type-safe argument parsing for Swift
Apache License 2.0
3.34k stars 321 forks source link

Ability to specify posix '-V', and modern 'version', 'help' for version and help #661

Open coolaj86 opened 2 months ago

coolaj86 commented 2 months ago

--version, -V, version

The posix tradition has been to use -V as short for --version (but -v is reserved for --verbose or sometimes --inverse), so naturally one of the first things I tried when I realized it was missing was to specify that - but there's no versionNames to match helpNames.

Many modern commands also use version, as an argument, without the -- flag prefix.

I'd like to be able to support all three.

--help, help, (no arguments)

Also, help is traditionally --help (with -h reserved for --human-readable), but many modern programs use help (or no arguments).

I'd like to be able to support --help, help, and no arguments simultaneously.

Can't override the defaults

Since I can't add the options I want, I thought perhaps I could disable the built-in help flag and parse my own, but doesn't seem to be working as expected either.

I would love it if this would either support the conventional help and version flags / arguments by way of options, or at least allow me to disable the built-in so that I can provide it in the most common configurations in the "happy path" configuration.

Sort-of Workaround

I think it's pretty reasonable to limit help to just --help and having help as a subcommand, and I could do the same with --version and version, but that doesn't give me -V.

I'm poking through the documentation to see if there's a way to just use the arguments parser and table generator with custom control-flow...