The main classes in this namespace are:
Cli | Provides methods for parsing command line input and running an indicated command. |
CliArgumentAttribute |
Specifies a class property that represents an argument which is a value that can be passed on the command line to a command or an option.
C#
Note that an argument is required if the decorated property does not have a default value (set via a property initializer), see Required property for details. Arguments: An argument is a value passed to an option or a command. The following examples show an argument for the verbosity option and an argument for the build command. console
console
|
CliCommandAsDelegate | Represents a definition class generated by the source generator for a command as delegate. |
CliCommandAttribute |
Specifies a class that represents a command which is a specific action that the command line application performs.
C#
Commands: A command in command-line input is a token that specifies an action or defines a group of related actions. For example:
Root commands: The root command is the one that specifies the name of the app's executable. For example, the dotnet command specifies the dotnet.exe executable. Subcommands: Most command-line apps support subcommands, also known as verbs. For example, the dotnet command has a run subcommand that you invoke by entering dotnet run. Subcommands can have their own subcommands. In dotnet tool install, install is a subcommand of tool. When you have repeating/common options and arguments for your commands, you can define them once in a base class and then share them by inheriting that base class in other command classes.Interfaces are also supported ! |
CliCommandBuilder | Represents a command builder generated by the source generator. |
CliContext | Supports command invocation by providing access to parse results and other services. |
CliExtensions | Provides extension methods for Cli. These are usually automatically generated by the source generator when current project supports a specific feature through a dependency, e.g. when you add package Microsoft.Extensions.DependencyInjection, dependency injection related extension methods will be available here. |
CliHelpBuilder |
Formats output to be shown to users to describe how to use a command line tool.
HelpBuilder is weirdly designed, i.e. it's hard to derive from that class due to static methods. CliHelpBuilder solves this problem by providing overridable methods, and it also adds color support. |
CliHelpBuilderDefault | Provides default formatting for help output. |
CliOptionAttribute |
Specifies a class property that represents an option which is a named parameter and a value for that parameter, that is used on the command line.
C#
Note that an option is required if the decorated property does not have a default value (set via a property initializer), see Required property for details. Options: An option is a named parameter that can be passed to a command. The POSIX convention is to prefix the option name with two hyphens (--). The following example shows two options: console
For some Windows command-line apps, you identify an option by using a leading slash (/) with the option name. For example: console
Bundling of single-character options are supported, also known as stacking. Bundled options are single-character option aliases specified together after a single hyphen prefix. For example if you have options "-a", "-b" and "-c", you can bundle them like "-abc". Only the last option can specify an argument. Note that if you have an explicit option named "-abc" then it will win over bundled options. |
CliSettings | Represents the settings used by the Cli. |
CliTheme | Represents the theme used by the Cli. These color and formatting option are mainly used by the help output. |
CliValidationExtensions | Provides extension methods related to validation for CliArgument and CliOption. |
ParseResultExtensions | Provides extension methods for ParseResult. |
StringExtensions | Provides extension methods for String. |
CliArgumentArity | Defines the arity of an option or argument. The arity refers to the number of values that can be passed on the command line. |
CliNameCasingConvention | Defines the character casing conventions to use for command, option and argument names. |
CliNamePrefixConvention | Defines the prefix conventions to use for option names and aliases. |
CliValidationRules | Defines validation rules for a CLI argument and a CLI option's argument. |