Feature Request: Ability to specify arguments before subcommands
See original GitHub issueIs your feature request related to a problem? Please describe. I’d like to create a commandline that allows me to do this:
program.exe -d value alpha // -d is currently ignored
program.exe -d value beta // -d is currently ignored
program.exe alpha -d value
program.exe beta -d value
That is… the ability to specify some argument before a subcommand, to specify some common argument. My subcommands are currently of an inherited form, where the base class has arguments such as “Database path”, and I’d like that to take affect no matter where it was placed.
The odd thing is, even if I specify the “-d” before my subcommand, no exception is thrown - but the argument is discarded. I noticed because my database hadn’t been modified … in the place I expected.
Describe the solution you’d like Either a parsing exception should be thrown, or the value should be used. In no case should the value be silently ignored.
Describe alternatives you’ve considered My workaround is to remember to put the subcommand first, always.
I vaguely recall other tools have the opposite issue - they will ignore common arguments that go after some “action”. The dotnet CLI seems to also exhibit this, although they’ll warn you about it.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
I confirm that SubcommandCycleException is thrown when running this code on master
This is already fixed in master at #239 and originally reported s #236
As the cyclic dependency is a manifestation of improper use. And fixing the cause makes the issue go away. I think its ok to wait until v2.4.0 to get the proper error message.