Home Basic usage Argument Usage
Post
Cancel

Argument Usage

Argument usage is a sample description explaining the usage of the argument, including the short and long names and format. Once the argument usage is set, if the user enters a wrong value, the usage set will be displayed as a hint to help the user correct the input.

The argument usage is displayed on the first column on the help output.

Usage example

1
2
3
4
5
6
7
8
9
10
11
12
13
public void Configure(ICliArgsContainer container)
        {
            // The user real name
            container.Register(
                CliArg.New<string>("Name")
                .WithLongName("name")
                .WithShortName("n")
                .WithDescription("The real name")
                // Here is the example usage
                .WithUsage($"-n|--name \"John Doe\"")
                .ValidatedWithRule(RegexRule.WithPattern("/^[a-z ,.'-]+$/i"))
            );
        }

Result on wrong input

Argument usage

Result on help requested

Argument usage on help

To generate a correct help output, Cliargs is generating automatically the argument usage if not set.