CliParseTDefinition(String, CliSettings) Method

Parses a command line string and returns the parse result.

Definition

Namespace: DotMake.CommandLine
Assembly: DotMake.CommandLine (in DotMake.CommandLine.dll) Version: 1.8.7
C#
public static ParseResult Parse<TDefinition>(
	string commandLine,
	CliSettings settings = null
)

Parameters

commandLine  String
The command line string that will be split into tokens as if it had been passed on the command line. Useful for testing command line input by just specifying it as a single string.
settings  CliSettings  (Optional)
The settings for the parser's grammar and behaviors.

Type Parameters

TDefinition
The definition class for the command. A command builder for this class should be automatically generated by the source generator.

Return Value

ParseResult
A ParseResult providing details about the parse operation.

Example

C#
//If you need to examine the parse result, such as errors:
var parseResult = Cli.Parse<RootCliCommand>("NewValueForArgument1 --option-1 NewValueForOption1");
if (parseResult.Errors.Count > 0)
{

}

See Also