OpenPetra
Free Administration Software for Non-Profits
Ict.Common.TCmdOpts Class Reference

This class contains all the commandline parameters. It takes a very easy approach for the formatting of commandline parameters that takes values. Basically it uses the format <flag>:<value>, eg -F:c:\path\to\file.txt where -F is the parameter name, and c:\path\to\file.txt is the value. More...

Public Member Functions

 TCmdOpts ()
 Creates a new object of this class and copies all the parameters that were passed on the command line into a string list. Uses the array of strings returned by Environment.GetCommandLineArgs More...
 
StringCollection GetOptKeys (string AStartingWith="")
 return all keys of available options More...
 
string GetOptValue (string AOpt)
 Returns the value of the given option. More...
 
Boolean IsFlagSet (string flag)
 Checks if the given flag is set. Note: Flag can be defined as either a standalone flag (eg. –verbose or -v) or can be the name of a parameter (eg. -F in -Fc:\path\to\file.txt). More...
 

Detailed Description

This class contains all the commandline parameters. It takes a very easy approach for the formatting of commandline parameters that takes values. Basically it uses the format <flag>:<value>, eg -F:c:\path\to\file.txt where -F is the parameter name, and c:\path\to\file.txt is the value.

if (commandLineOpts.IsFlagSet("hello")) then { Console.Writeline(commandLineOpts.GetOptValue("hello")); } /example>

Constructor & Destructor Documentation

◆ TCmdOpts()

Ict.Common.TCmdOpts.TCmdOpts ( )
inline

Creates a new object of this class and copies all the parameters that were passed on the command line into a string list. Uses the array of strings returned by Environment.GetCommandLineArgs

Returns
void

Member Function Documentation

◆ GetOptKeys()

StringCollection Ict.Common.TCmdOpts.GetOptKeys ( string  AStartingWith = "")
inline

return all keys of available options

Parameters
AStartingWithonly keys that start with this string

◆ GetOptValue()

string Ict.Common.TCmdOpts.GetOptValue ( string  AOpt)
inline

Returns the value of the given option.

Parameters
AOptThe option/parameter to look for.
Returns
The value of the option, or throws an exception if the value was not found

◆ IsFlagSet()

Boolean Ict.Common.TCmdOpts.IsFlagSet ( string  flag)
inline

Checks if the given flag is set. Note: Flag can be defined as either a standalone flag (eg. –verbose or -v) or can be the name of a parameter (eg. -F in -Fc:\path\to\file.txt).

Parameters
flagFlag to search for in the list of parameters.
Returns
true
if flag was set, otherwise
false

The documentation for this class was generated from the following file: