commandline
commandline copied to clipboard
Default verb handling
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
This wiki page may help.
@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.
Why you are using verb in the scenario of one Option class?
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?
default verb can help. Define verb as:
[Verb("subcommand",true,"tool help")] //default help
and you can use it as you described above.
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.