-
Notifications
You must be signed in to change notification settings - Fork 2
Help_Text
CommandLine
provides automatic help text generation feature. If application is called with /?
, -?
, /h
, -h
, /help
or --help
option, then the help text will be displayed.
The following application will be used for demonstration:
[Description("This test application. Type /? for help.")]
public class Program
{
private static int Main(string[] arguments)
{
/* ... */
}
[Description("Says hello to specified 'name'.")]
public static int Hello(
[Description("Name to greet.")]
string name
)
{
/* ... */
}
}
Requesting help without specifying a verb displays a list of available verbs.
>myapp /?
This test application. Type /? for help.
Verbs:
HELLO Says hello to specified 'name'.
If a verb is specified before of the request for help option, then detailed help for that verb will be displayed:
>myapp HELLO /?
HELLO --name <TEXT>
Says hello to specified 'name'.
Options:
--name Name to greet.
Help is displayed for nested verbs as well.
You can customize the help text by specifying DescriptionAttribute
or HelpTextAttribute
attributes on the class, method or parameter.
In addition to this, you can hide the verb from the reference using HiddenAttribute
attribute. This will not prevent the use of this verb. If you want to mark a method as "not a verb" then use NonVerbAttribute
attribute.
If you want to change the text used when displaying help, then you need to provide your own IHelpTextProvider
service via you own IServiceProvider
.