Skip to content

Help_Text

Denis Zykov edited this page Jan 10, 2024 · 5 revisions

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
    )
    {
        /* ... */
    }
}

General help

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

Verb help

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.

Sub-verb help

Help is displayed for nested verbs as well.

Customization

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.

Localization

If you want to change the text used when displaying help, then you need to provide your own IHelpTextProvider service via you own IServiceProvider.

Clone this wiki locally