Argu


ArgumentParser<'Template> Type

Namespace: Argu

Assembly: Argu.dll

Base Type: ArgumentParser

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 executable name.
    ?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 executable name.

?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(ctorExpr)

Full Usage: this.GetArgumentCaseInfo(ctorExpr)

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(value)

Full Usage: this.GetArgumentCaseInfo(value)

Parameters:
    value : 'Template - Argument instance.

Returns: ArgumentCaseInfo

Gets argument metadata for given argument instance.

value : 'Template

Argument instance.

Returns: ArgumentCaseInfo

this.GetSubCommandParser(expr)

Full Usage: this.GetSubCommandParser(expr)

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(value)

Full Usage: this.GetTag(value)

Parameters:
    value : 'Template - Argument instance.

Returns: int

Gets the F# union tag representation for given argument

value : 'Template

Argument instance.

Returns: int

this.Parse(?inputs, ?configurationReader, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage)

Full Usage: this.Parse(?inputs, ?configurationReader, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage)

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(?inputs, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage)

Full Usage: this.ParseCommandLine(?inputs, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage)

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(configurationReader, ?ignoreMissing)

Full Usage: this.ParseConfiguration(configurationReader, ?ignoreMissing)

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(args, ?printComments)

Full Usage: this.PrintAppSettingsArguments(args, ?printComments)

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(args)

Full Usage: this.PrintCommandLineArguments(args)

Parameters:
    args : 'Template list

Returns: string[]

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

args : 'Template list
Returns: string[]

this.PrintCommandLineArgumentsFlat(args)

Full Usage: this.PrintCommandLineArgumentsFlat(args)

Parameters:
    args : 'Template list

Returns: string

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

args : 'Template list
Returns: string

this.ToParseResults(inputs)

Full Usage: this.ToParseResults(inputs)

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

Returns: ParseResults<'Template>

Converts a sequence of template argument inputs into a ParseResults instance

inputs : seq<'Template>

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.