Skip to content

Support for default verb? #494

Open
Open
@alexreg

Description

@alexreg

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?

Activity

alexreg

alexreg commented on Oct 16, 2017

@alexreg
Author

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

nemec

nemec commented on Oct 16, 2017

@nemec
Collaborator

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

alexreg commented on Oct 16, 2017

@alexreg
Author

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

alexreg commented on Oct 16, 2017

@alexreg
Author

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

alexreg commented on Oct 16, 2017

@alexreg
Author

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

nemec commented on Oct 17, 2017

@nemec
Collaborator

You're right - it is not obvious that one generic argument is interpreted as an Options class but multiple are considered Verbs.

TheFanatr

TheFanatr commented on Oct 21, 2017

@TheFanatr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alexreg@nemec@TheFanatr

        Issue actions

          Support for default verb? · Issue #494 · gsscoder/commandline