Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for default verb? #494

Open
alexreg opened this issue Oct 16, 2017 · 7 comments
Open

Support for default verb? #494

alexreg opened this issue Oct 16, 2017 · 7 comments

Comments

@alexreg
Copy link

alexreg commented Oct 16, 2017

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?

@alexreg
Copy link
Author

alexreg commented Oct 16, 2017

Furthermore, is it possible to have global options while still having a verb?

@nemec
Copy link
Collaborator

nemec commented 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
Copy link
Author

alexreg commented Oct 16, 2017

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!

@alexreg
Copy link
Author

alexreg commented Oct 16, 2017

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?

@alexreg
Copy link
Author

alexreg commented 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
Copy link
Collaborator

nemec commented 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
Copy link

Just to clarify, is there a workaround by using GlobalOptions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants