Skip to content

Default verb handling #655

@lutz

Description

@lutz

What is the best way to support a default verb? Currently it seems to be no way to define some verbs and one default verb without a name.

call tool.exe -> default verb handling
call tool.exe [verbname] -> verb handling

Thanks for this great library!

Maybe it is in context the same behaviour like #652

Activity

moh-hassan

moh-hassan commented on Jun 30, 2020

@moh-hassan
Collaborator

This wiki page may help.

lutz

lutz commented on Jul 1, 2020

@lutz
Author

@moh-hassan Thank you for answering. I knew this wiki page but the problem of using isDefault like [Verb("copy",isDefault: true, HelpText = "Copy some stuff" )] is that i must define a name for the verb and this is also showing in the helptext and so on. It is a little bit described here.

moh-hassan

moh-hassan commented on Jul 1, 2020

@moh-hassan
Collaborator

Why you are using verb in the scenario of one Option class?

lutz

lutz commented on Jul 2, 2020

@lutz
Author

When i have a console app called tool then i want to use a default implementation with options like

tool
# or
tool --option1 --option2

and usage of verb for subcommand like

tool subcommand
# or
tool subcommand --option3 --option4

so this is currently not possible or?

moh-hassan

moh-hassan commented on Jul 2, 2020

@moh-hassan
Collaborator

default verb can help.
Define verb as:

[Verb("subcommand",true,"tool help")]   //default help

and you can use it as you described above.

wayneyaoo

wayneyaoo commented on Nov 28, 2021

@wayneyaoo

Hi @moh-hassan, sorry to bring up this question again. I had the same question too and .. I do know the existence of default verb but it still doesn't do what I want. The issue is that I have to explicitly define the name and it always shows up in the help text. (Hidden property is not what I want since I still need help text for it).

This describes the exact question.

When i have a console app called tool then i want to use a default implementation with options like

tool
# or
tool --option1 --option2

and usage of verb for subcommand like

tool subcommand
# or
tool subcommand --option3 --option4

so this is currently not possible or?

is it possible that tool --option1 --option2 itself is interpreted as non-verb option? or you're suggesting that once there's a "Verb Option" in the whole parsing tree, all options have to be verb and it's just the difference of "default/non-default", "hidden/visible"?

Also to be more specific, is there anyway I can define options like this without tweaking the help text rendering

> ./myapplication help
Usage: some usage text

Options:
--login, -l         Do login
--service-version          check service version

Commands:
someDefaultVerb (Default Verb)  <- if I define default verb how can I remove this line
verb1      verb1 help text
verb2      verb2 help text

as you can see ./myapplication --login here makes sense independent of other verbs. How can I achieve this? Thanks very much.

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @moh-hassan@wayneyaoo@lutz

        Issue actions

          Default verb handling · Issue #655 · commandlineparser/commandline