CLI flags/switches and subcommands
- Vorherrschende Sprache
- Common Lisp
- Sterne
- 32
- Forks
- 1
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
We can easily use subcommands to support something like `./frob create thing`, where "create" is the subcommand and "thing" is a rest argument. We can add flags/switches as well like this: `./frob create --beautiful thing`. However, there's no built-in way (apparently) to process the following without analyzing the arguments manually (which defeats the purpose of the library): `./frob create thing --value 42`.
I think a (hackish?) way of supporting this use case would be to always insert a terminating subcommand. So, the above would actually be processed as if the user had written `./frob create thing --value 42 now-please-do-it` and "now-please-do-it" were a subcommand that inherited all the arguments of the "create" subcommand (inheritance which, by the way, is already possible, I don't know if by design or by accident, but I'm using it). And, if we use "--" instead of "now-please-do-it", and enable it for all subcommands, we also obtain the common pattern of using "--" to mean "please process everything after as REST arguments", e.g. in `./frob delete this that --gently -- --also-delete-this --this-is-not-a-flag this-is-not-a-subcommand`.
If you're interested in the use case, and in the proposed solution design, I'll gladly provide a PR.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.