C# Class ToolBelt.CommandLineParser

Command line parser.
Datei anzeigen Open project: jlyonsmith/ToolBelt Class Usage Examples

Public Methods

Method Description
CommandLineParser ( object argTarget, Type resourceReaderType = null, CommandLineParserFlags flags = CommandLineParserFlags.Default ) : System

Initializes a new instance of the CommandLineParser class. Provides a resource reader for localization of the command line arguments. String specified in the command line attributes are used to look up corresponding localized strings in the resources. Also provides flags to control parsing.

GetArgumentString ( ) : string

Gets all set arguments in the target as a valid command line string

GetUsage ( string command ) : string

Gets the usage string for a specific command.

GetUsage ( string command, int lineLength ) : string

Gets the usage string for a specific command.

ParseAndSetTarget ( IEnumerable argStrings ) : void

Parses the supplied command line arguments and sets the target objects properties.

Private Methods

Method Description
ExternalGetString ( string s ) : string
GetCommandHelpLines ( int lineLength, StringBuilder helpText ) : void
GetDefaultArgumentValueHint ( string command ) : string
GetDescriptionHelpLines ( string command, int lineLength, StringBuilder helpText ) : void
GetExampleHelpLines ( int lineLength, StringBuilder helpText ) : void
GetSwitchesHelpLines ( string command, int lineLength, StringBuilder helpText ) : void
GetSyntaxHelpLine ( string command, StringBuilder helpText ) : void
GetUnprocessedArgumentValueHint ( string command ) : string
HasArguments ( string command ) : bool
IsValidArgumentForCommand ( CommandLineArgument argument, string command ) : bool

Is the argument valid of for this command?

IsValidCommand ( string command ) : bool

Is this a valid command.

LazyGenerateCommandArguments ( ) : void

Method Details

CommandLineParser() public method

Initializes a new instance of the CommandLineParser class. Provides a resource reader for localization of the command line arguments. String specified in the command line attributes are used to look up corresponding localized strings in the resources. Also provides flags to control parsing.
is a null reference.
public CommandLineParser ( object argTarget, Type resourceReaderType = null, CommandLineParserFlags flags = CommandLineParserFlags.Default ) : System
argTarget object The into which the command line arguments are placed.
resourceReaderType System.Type A resource reader object with a GetString method
flags CommandLineParserFlags See .
return System

GetArgumentString() public method

Gets all set arguments in the target as a valid command line string
public GetArgumentString ( ) : string
return string

GetUsage() public method

Gets the usage string for a specific command.
public GetUsage ( string command ) : string
command string The command for which to obtain usage. Pass null to obtain default usage.
return string

GetUsage() public method

Gets the usage string for a specific command.
public GetUsage ( string command, int lineLength ) : string
command string The command for which to obtain usage. Pass null to obtain default usage.
lineLength int /// Number of columns to format the output for. Pass -1 to format for the active console. /// If there is no console window the default will be 79. Any line length below 39 is rounded up to 39. ///
return string

ParseAndSetTarget() public method

Parses the supplied command line arguments and sets the target objects properties.
public ParseAndSetTarget ( IEnumerable argStrings ) : void
argStrings IEnumerable
return void