Header menu logo Argu

ArgumentParser<'Template> Type

The Argu type generates an argument parser given a type argument that is an F# discriminated union. It can then be used to parse command line arguments or XML configuration.

Constructors

Constructor Description

ArgumentParser(?programName, ?helpTextMessage, ?usageStringCharacterWidth, ?errorHandler, ?checkStructure)

Full Usage: ArgumentParser(?programName, ?helpTextMessage, ?usageStringCharacterWidth, ?errorHandler, ?checkStructure)

Parameters:
    ?programName : string - Program identifier, e.g. 'cat'. Defaults to the current running executable per Assembly.GetEntryAssembly().
    ?helpTextMessage : string - Message that will be displayed at the top of the help text.
    ?usageStringCharacterWidth : int - Text width used when formatting the usage string. Defaults to 80 chars.
    ?errorHandler : IExiter - The implementation of IExiter used for error handling. Exception is default.
    ?checkStructure : bool - Indicate if the structure of the arguments discriminated union should be checked for errors.

Returns: ArgumentParser<'Template>

Creates a new parser instance based on supplied F# union template.

?programName : string

Program identifier, e.g. 'cat'. Defaults to the current running executable per Assembly.GetEntryAssembly().

?helpTextMessage : string

Message that will be displayed at the top of the help text.

?usageStringCharacterWidth : int

Text width used when formatting the usage string. Defaults to 80 chars.

?errorHandler : IExiter

The implementation of IExiter used for error handling. Exception is default.

?checkStructure : bool

Indicate if the structure of the arguments discriminated union should be checked for errors.

Returns: ArgumentParser<'Template>

Instance members

Instance member Description

this.GetArgumentCaseInfo

Full Usage: this.GetArgumentCaseInfo

Parameters:
    ctorExpr : Expr<('Fields -> 'Template)> - Quoted union case constructor.

Returns: ArgumentCaseInfo

Gets argument metadata for given union case constructor

ctorExpr : Expr<('Fields -> 'Template)>

Quoted union case constructor.

Returns: ArgumentCaseInfo

this.GetArgumentCaseInfo

Full Usage: this.GetArgumentCaseInfo

Parameters:
    value : 'Template - Argument instance.

Returns: ArgumentCaseInfo

Gets argument metadata for given argument instance.

value : 'Template

Argument instance.

Returns: ArgumentCaseInfo

this.GetSubCommandParser

Full Usage: this.GetSubCommandParser

Parameters:
    expr : Expr<(ParseResults<'SubTemplate> -> 'Template)> - Expression providing the subcommand union constructor.

Returns: ArgumentParser<'SubTemplate>

Gets a subparser associated with specific subcommand instance

expr : Expr<(ParseResults<'SubTemplate> -> 'Template)>

Expression providing the subcommand union constructor.

Returns: ArgumentParser<'SubTemplate>

this.GetTag

Full Usage: this.GetTag

Parameters:
    value : 'Template - Argument instance.

Returns: int

Gets the F# union tag representation for given argument

value : 'Template

Argument instance.

Returns: int

this.Parse

Full Usage: this.Parse

Parameters:
    ?inputs : string[] - The command line input. Taken from System.Environment if not specified.
    ?configurationReader : IConfigurationReader - Configuration reader used to source the arguments. Defaults to the AppSettings configuration of the current process.
    ?ignoreMissing : bool - Ignore errors caused by the Mandatory attribute. Defaults to false.
    ?ignoreUnrecognized : bool - Ignore CLI arguments that do not match the schema. Defaults to false.
    ?raiseOnUsage : bool - Treat '--help' parameters as parse errors. Defaults to true.

Returns: ParseResults<'Template>

Parse both command line args and supplied configuration reader. Results are merged with command line args overriding configuration parameters.

?inputs : string[]

The command line input. Taken from System.Environment if not specified.

?configurationReader : IConfigurationReader

Configuration reader used to source the arguments. Defaults to the AppSettings configuration of the current process.

?ignoreMissing : bool

Ignore errors caused by the Mandatory attribute. Defaults to false.

?ignoreUnrecognized : bool

Ignore CLI arguments that do not match the schema. Defaults to false.

?raiseOnUsage : bool

Treat '--help' parameters as parse errors. Defaults to true.

Returns: ParseResults<'Template>

this.ParseCommandLine

Full Usage: this.ParseCommandLine

Parameters:
    ?inputs : string[] - The command line input. Taken from System.Environment if not specified.
    ?ignoreMissing : bool - Ignore errors caused by the Mandatory attribute. Defaults to false.
    ?ignoreUnrecognized : bool - Ignore CLI arguments that do not match the schema. Defaults to false.
    ?raiseOnUsage : bool - Treat '--help' parameters as parse errors. Defaults to true.

Returns: ParseResults<'Template>

Parse command line arguments only.

?inputs : string[]

The command line input. Taken from System.Environment if not specified.

?ignoreMissing : bool

Ignore errors caused by the Mandatory attribute. Defaults to false.

?ignoreUnrecognized : bool

Ignore CLI arguments that do not match the schema. Defaults to false.

?raiseOnUsage : bool

Treat '--help' parameters as parse errors. Defaults to true.

Returns: ParseResults<'Template>

this.ParseConfiguration

Full Usage: this.ParseConfiguration

Parameters:
    configurationReader : IConfigurationReader - Configuration reader used to source the arguments. Defaults to the AppSettings configuration of the current process.
    ?ignoreMissing : bool - Ignore errors caused by the Mandatory attribute. Defaults to false.

Returns: ParseResults<'Template>

Parse arguments using specified configuration reader only. This defaults to the AppSettings configuration of the current process.

configurationReader : IConfigurationReader

Configuration reader used to source the arguments. Defaults to the AppSettings configuration of the current process.

?ignoreMissing : bool

Ignore errors caused by the Mandatory attribute. Defaults to false.

Returns: ParseResults<'Template>

this.PrintAppSettingsArguments

Full Usage: this.PrintAppSettingsArguments

Parameters:
    args : 'Template list - The parameters that fill out the XML document.
    ?printComments : bool - Print XML comments over every configuration entry.

Returns: string

Prints parameters in App.Config format.

args : 'Template list

The parameters that fill out the XML document.

?printComments : bool

Print XML comments over every configuration entry.

Returns: string

this.PrintCommandLineArguments

Full Usage: this.PrintCommandLineArguments

Parameters:
    args : 'Template list

Returns: string[]

Prints parameters in command line format. Useful for argument string generation.

args : 'Template list
Returns: string[]

this.PrintCommandLineArgumentsFlat

Full Usage: this.PrintCommandLineArgumentsFlat

Parameters:
    args : 'Template list

Returns: string

Prints parameters in command line format. Useful for argument string generation.

args : 'Template list
Returns: string

this.ProgramName

Full Usage: this.ProgramName

Returns: string

The Program Name, as used when rendering help messages. Can be overridden via the programName constructor argument.

Returns: string

this.ToParseResults

Full Usage: this.ToParseResults

Parameters:
    inputs : 'Template seq - Argument input sequence.

Returns: ParseResults<'Template>

Converts a sequence of template argument inputs into a ParseResults instance

inputs : 'Template seq

Argument input sequence.

Returns: ParseResults<'Template>

Static members

Static member Description

ArgumentParser.CheckStructure()

Full Usage: ArgumentParser.CheckStructure()

Force a check of the discriminated union structure.

Type something to start searching.