Prajna


ArgumentParser

Utility class to parse commandline argument. Each argument is in the form of -pattern param, and the programmer can supplied a default value for each parameter. Please note that the pattern is case insensitive prefix matched, so pattern -dir will match "-directory" "-DIRECT". Please design your commandline argument pattern with different prefix.

Constructors

ConstructorDescription
new(arguments)
Signature: (arguments:string []) -> ArgumentParser

Constructor that takes an array of string that represents the command line arguments

Instance members

Instance memberDescription
AllParsed(usage)
Signature: usage:string -> bool

Return true if all argument has been parsed, otherwise, return false, with usage stagement (including trace usage) printed.

ArgExists(arg)
Signature: arg:string -> bool

Does a certain argument exists

ParseBoolean(arg, defVal)
Signature: (arg:string * defVal:bool) -> bool

Parse a Boolean argument, with a supplied default value pattern to arg default value when pattern does not exist

ParseDouble(arg, defVal)
Signature: (arg:string * defVal:float) -> float

Parse a float argument (double), with a supplied default value pattern to arg default value when pattern does not exist

ParseFloat(arg, defVal)
Signature: (arg:string * defVal:float) -> float

Parse a double argument, with a supplied default value pattern to arg default value when pattern does not exist

ParseInt(arg, defVal)
Signature: (arg:string * defVal:int) -> int

Parse a int32 argument, with a supplied default value pattern to arg default value when pattern does not exist

ParseInt64(arg, defVal)
Signature: (arg:string * defVal:int64) -> int64

Parse a Int64 argument, with a supplied default value pattern to arg default value when pattern does not exist

ParseInts(arg, defVal)
Signature: (arg:string * defVal:int []) -> int []

Parse a int[] argument, where multiple values can appear by using -arg param1 -arg param2 -arg param3. pattern to arg default value when pattern does not exist

ParseString(arg, defVal)
Signature: (arg:string * defVal:string) -> string

Parse a string argument, with a supplied default value pattern to arg default value when pattern does not exist

ParseStrings(arg, defVal)
Signature: (arg:string * defVal:string []) -> string []

Parse a string[] argument, where multiple values The parameter can be set using -arg param1,param2,param3 where , is the delimiter, or using -arg param1 -arg param2 -arg param3 pattern to arg default value when pattern does not exist

PrintUsage(usage)
Signature: usage:string -> unit

print a usage statement, combined with default trace usage information.

RemainingArgs
Signature: string []

Return remaining args that is unparsed.

Fork me on GitHub