commandline
commandline copied to clipboard
Support for default verb?
Is there any support for some sort of "default" verb? That is, a verb that gets executed when no verb is actually specified. Perhaps an existing verb can be marked as default, even?
Furthermore, is it possible to have global options while still having a verb?
This is a duplicate of #490. Unfortunately, no it isn't possible. With the way verbs work in the current version (e.g. Parse<VerbA, VerbB>(args)
) I'm having a hard time thinking of a way to add a default verb and global options.
Thanks for the quick reply, @nemec. What about a simple IsDefault
property of the Verb
attribute. The name of the verb should also be optional in this case. As for global options, what about a special Options generic argument that inherits from a (dummy) GlobalOptions class, or something similar?
Update: Actually, quite a nice solution that already works is simply inheriting from a GlobalOptions
class!
I'm currently trying to come up with a workaround for this, but I can't get the NoVerbSelectedError
, nor the BadVerbSelectedError
. It just runs my (one and only) options handler instead. Using the latest beta here. Any known issue with that right now?
Update: it seems I have to specify at least two options types to ParseArguments
for these errors to kick in! I see why, though perhaps this should be documented.
You're right - it is not obvious that one generic argument is interpreted as an Options class but multiple are considered Verbs.
Just to clarify, is there a workaround by using GlobalOptions?