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) Parameter Types:
  • ?programName : string
  • ?helpTextMessage : string
  • ?usageStringCharacterWidth : int
  • ?errorHandler : IExiter
  • ?checkStructure : bool

Return Type: ArgumentParser<'Template>
Signature: (programName: string * helpTextMessage: string * usageStringCharacterWidth: int * errorHandler: IExiter * checkStructure: bool) -> ArgumentParser<'Template>

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

Parameters

programName

Program identifier, e.g. 'cat'. Defaults to the current executable name.

helpTextMessage

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

usageStringCharacterWidth

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

errorHandler

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

checkStructure

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


Parameter Types:
  • ?programName : string
  • ?helpTextMessage : string
  • ?usageStringCharacterWidth : int
  • ?errorHandler : IExiter
  • ?checkStructure : bool
Return Type: ArgumentParser<'Template>

Instance members

Instance member Description
this.GetArgumentCaseInfo(ctorExpr)
Full Usage:
this.GetArgumentCaseInfo(ctorExpr) Parameter Types:
  • ctorExpr : Expr<('Fields -> 'Template)>

Return Type: ArgumentCaseInfo
Signature: (ctorExpr: Expr<('Fields -> 'Template)>) -> ArgumentCaseInfo

Gets argument metadata for given union case constructor

Parameters

ctorExpr

Quoted union case constructor.


Parameter Types:
  • ctorExpr : Expr<('Fields -> 'Template)>
Return Type: ArgumentCaseInfo
this.GetArgumentCaseInfo(value)
Full Usage:
this.GetArgumentCaseInfo(value) Parameter Types:
  • value : 'Template

Return Type: ArgumentCaseInfo
Signature: (value: 'Template) -> ArgumentCaseInfo

Gets argument metadata for given argument instance.

Parameters

value

Argument instance.


Parameter Types:
  • value : 'Template
Return Type: ArgumentCaseInfo
this.GetSubCommandParser(expr)
Full Usage:
this.GetSubCommandParser(expr) Parameter Types:
  • expr : Expr<(ParseResults<'SubTemplate> -> 'Template)>

Return Type: ArgumentParser<'SubTemplate>
Signature: (expr: Expr<(ParseResults<'SubTemplate> -> 'Template)>) -> ArgumentParser<'SubTemplate>

Gets a subparser associated with specific subcommand instance

Parameters

expr

Expression providing the subcommand union constructor.


Parameter Types:
  • expr : Expr<(ParseResults<'SubTemplate> -> 'Template)>
Return Type: ArgumentParser<'SubTemplate>
this.GetTag(value)
Full Usage:
this.GetTag(value) Parameter Types:
  • value : 'Template

Return Type: int
Signature: (value: 'Template) -> int

Gets the F# union tag representation for given argument

Parameters

value

Argument instance.


Parameter Types:
  • value : 'Template
Return Type: int
this.Parse(?inputs, ?configurationReader, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage)
Full Usage:
this.Parse(?inputs, ?configurationReader, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage) Parameter Types:
  • ?inputs : string []
  • ?configurationReader : IConfigurationReader
  • ?ignoreMissing : bool
  • ?ignoreUnrecognized : bool
  • ?raiseOnUsage : bool

Return Type: ParseResults<'Template>
Signature: (inputs: string [] * configurationReader: IConfigurationReader * ignoreMissing: bool * ignoreUnrecognized: bool * raiseOnUsage: bool) -> ParseResults<'Template>

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

Parameters

inputs

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

configurationReader

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

ignoreMissing

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

ignoreUnrecognized

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

raiseOnUsage

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


Parameter Types:
  • ?inputs : string []
  • ?configurationReader : IConfigurationReader
  • ?ignoreMissing : bool
  • ?ignoreUnrecognized : bool
  • ?raiseOnUsage : bool
Return Type: ParseResults<'Template>
this.ParseCommandLine(?inputs, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage)
Full Usage:
this.ParseCommandLine(?inputs, ?ignoreMissing, ?ignoreUnrecognized, ?raiseOnUsage) Parameter Types:
  • ?inputs : string []
  • ?ignoreMissing : bool
  • ?ignoreUnrecognized : bool
  • ?raiseOnUsage : bool

Return Type: ParseResults<'Template>
Signature: (inputs: string [] * ignoreMissing: bool * ignoreUnrecognized: bool * raiseOnUsage: bool) -> ParseResults<'Template>

Parse command line arguments only.

Parameters

inputs

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

ignoreMissing

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

ignoreUnrecognized

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

raiseOnUsage

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


Parameter Types:
  • ?inputs : string []
  • ?ignoreMissing : bool
  • ?ignoreUnrecognized : bool
  • ?raiseOnUsage : bool
Return Type: ParseResults<'Template>
this.ParseConfiguration(configurationReader, ?ignoreMissing)
Full Usage:
this.ParseConfiguration(configurationReader, ?ignoreMissing) Parameter Types:
  • configurationReader : IConfigurationReader
  • ?ignoreMissing : bool

Return Type: ParseResults<'Template>
Signature: (configurationReader: IConfigurationReader * ignoreMissing: bool) -> ParseResults<'Template>

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

Parameters

configurationReader

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

ignoreMissing

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


Parameter Types:
  • configurationReader : IConfigurationReader
  • ?ignoreMissing : bool
Return Type: ParseResults<'Template>
this.PrintAppSettingsArguments(args, ?printComments)
Full Usage:
this.PrintAppSettingsArguments(args, ?printComments) Parameter Types:
  • args : 'Template list
  • ?printComments : bool

Return Type: string
Signature: (args: 'Template list * printComments: bool) -> string

Prints parameters in App.Config format.

Parameters

args

The parameters that fill out the XML document.

printComments

Print XML comments over every configuration entry.


Parameter Types:
  • args : 'Template list
  • ?printComments : bool
Return Type: string
this.PrintCommandLineArguments(args)
Full Usage:
this.PrintCommandLineArguments(args) Parameter Types:
  • args : 'Template list

Return Type: string []
Signature: (args: 'Template list) -> string []

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


Parameter Types:
  • args : 'Template list
Return Type: string []
this.PrintCommandLineArgumentsFlat(args)
Full Usage:
this.PrintCommandLineArgumentsFlat(args) Parameter Types:
  • args : 'Template list

Return Type: string
Signature: (args: 'Template list) -> string

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


Parameter Types:
  • args : 'Template list
Return Type: string
this.ToParseResults(inputs)
Full Usage:
this.ToParseResults(inputs) Parameter Types:
  • inputs : seq<'Template>

Return Type: ParseResults<'Template>
Signature: (inputs: seq<'Template>) -> ParseResults<'Template>

Converts a sequence of template argument inputs into a ParseResults instance

Parameters

inputs

Argument input sequence.


Parameter Types:
  • inputs : seq<'Template>
Return Type: ParseResults<'Template>

Static members

Static member Description
ArgumentParser.CheckStructure()
Full Usage:
ArgumentParser.CheckStructure()
Signature: unit -> unit

Force a check of the discriminated union structure.


Fork me on GitHub