commandline icon indicating copy to clipboard operation
commandline copied to clipboard

Default verb handling

Open lutz opened this issue 4 years ago • 6 comments

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

lutz avatar Jun 26 '20 11:06 lutz

This wiki page may help.

moh-hassan avatar Jun 30 '20 14:06 moh-hassan

@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.

lutz avatar Jul 01 '20 12:07 lutz

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

moh-hassan avatar Jul 01 '20 21:07 moh-hassan

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?

lutz avatar Jul 02 '20 12:07 lutz

default verb can help. Define verb as:

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

and you can use it as you described above.

moh-hassan avatar Jul 02 '20 15:07 moh-hassan

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.

wayneyaoo avatar Nov 28 '21 05:11 wayneyaoo