You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
Activity
alexreg commentedon Oct 16, 2017
Furthermore, is it possible to have global options while still having a verb?
nemec commentedon Oct 16, 2017
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.alexreg commentedon Oct 16, 2017
Thanks for the quick reply, @nemec. What about a simple
IsDefault
property of theVerb
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!alexreg commentedon Oct 16, 2017
I'm currently trying to come up with a workaround for this, but I can't get the
NoVerbSelectedError
, nor theBadVerbSelectedError
. It just runs my (one and only) options handler instead. Using the latest beta here. Any known issue with that right now?alexreg commentedon Oct 16, 2017
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.nemec commentedon Oct 17, 2017
You're right - it is not obvious that one generic argument is interpreted as an Options class but multiple are considered Verbs.
TheFanatr commentedon Oct 21, 2017
Just to clarify, is there a workaround by using GlobalOptions?