BALL
1.4.79
|
#include <BALL/FORMAT/commandlineParser.h>
Public Member Functions | |
CommandlineParser (String tool_name, String tool_description, String tool_version, String build_date, String category="") | |
void | setToolManual (const String &manual) |
void | registerParameter (String name, String description, ParameterType type, bool mandatory=false, String default_value="", bool hidden=false) |
void | registerFlag (String name, String description, bool default_gui_value=false, bool hidden=false) |
void | registerAdvancedParameters (Options &options) |
void | setParameterAsAdvanced (String name) |
void | setParameterRestrictions (String par_name, double min_value, double max_value) |
void | setParameterRestrictions (String par_name, list< String > &allowed_values) |
void | setOutputFormatSource (String output_parname, String input_parname) |
void | setSupportedFormats (String par_name, String supported_formats) |
void | parse (int argc, char *argv[]) |
void | copyAdvancedParametersToOptions (Options &options) |
const String & | get (String name) |
bool | has (String name) |
const list< String > & | getList (String name) |
void | printHelp (const std::set< String > ¶meter_names=std::set< String >(), bool show_manual=true) |
void | printToolInfo () |
const String & | getStartTime () |
const String & | getStartCommand () |
Static Public Attributes | |
static const String | NOT_FOUND |
static const list< String > | EMTPY_LIST |
Class for parsing parameters specified on the command line.
Register the parameters and flags of your tool with registerParameter(), resp. registerFlag() and have the command-line parsed with parse(). After this, you can retrieve the values of all parameters with get().
In addition to this, you can also register a tool-manual text, define restrictions on parameters and register file-formats that are supported for in- or output-files.
If the parameter '-write_par somefilename.xml' is given to the program, an xml-based parameter-file will be automatically written, containing the specification the tool, all its parameters and all parameter values used on the commend-line.
If the parameter '-par somefilename.xml' is used, such a file can be read, so that the parameter-values stored in it will be used. However, if, although this is not necessary, parameters (other than -par) are specified on the command-line, their values will automatically overload those stored in the xml-file.
The parameter '-env' allows to differentiate between command line ('cmdline') behaviour and special adaptions to workflow systems like galaxy or knime.
Definition at line 45 of file commandlineParser.h.
BALL::CommandlineParser::CommandlineParser | ( | String | tool_name, |
String | tool_description, | ||
String | tool_version, | ||
String | build_date, | ||
String | category = "" |
||
) |
void BALL::CommandlineParser::copyAdvancedParametersToOptions | ( | Options & | options | ) |
Copies names and values of all advanced parameters to the given Options object.
Returns the value for a given parameter name.
Example: For "-o outfile.sdf", CommandlineParser::get("o") will return "outfile.sdf".
Returns a parameter-list for a given parameter name.
Example: For "-i infile1.sdf infile2.sdf", CommandlineParser::getList("i") will return a vector containing 'infile1.sdf' and infile2.sdf'.
const String& BALL::CommandlineParser::getStartCommand | ( | ) |
Get the exact command with which the tool was started on the command-line.
const String& BALL::CommandlineParser::getStartTime | ( | ) |
Find out whether a the parameter or flag has been specified on the command-line.
void BALL::CommandlineParser::parse | ( | int | argc, |
char * | argv[] | ||
) |
Parse all parameters found in the command line
void BALL::CommandlineParser::printHelp | ( | const std::set< String > & | parameter_names = std::set< String >() , |
bool | show_manual = true |
||
) |
Print information about about all registered parameters.
If 'parameter_names' is specified, only information those parameters is shown.
void BALL::CommandlineParser::printToolInfo | ( | ) |
void BALL::CommandlineParser::registerAdvancedParameters | ( | Options & | options | ) |
void BALL::CommandlineParser::registerFlag | ( | String | name, |
String | description, | ||
bool | default_gui_value = false , |
||
bool | hidden = false |
||
) |
void BALL::CommandlineParser::registerParameter | ( | String | name, |
String | description, | ||
ParameterType | type, | ||
bool | mandatory = false , |
||
String | default_value = "" , |
||
bool | hidden = false |
||
) |
In case of output-files, this functions allows to specify the name of an input-parameter, whose format should be used for the given output-parameter.
Note, that this function will only have an effect on the creation of config-files for workflow-systems (Galaxy, Knime, etc.) and not for the command-line interface, where the user will directly specify output-filenames.
void BALL::CommandlineParser::setParameterAsAdvanced | ( | String | name | ) |
void BALL::CommandlineParser::setParameterRestrictions | ( | String | par_name, |
double | min_value, | ||
double | max_value | ||
) |
Register the minimal and maximal allowed value for a numerical parameter.
void BALL::CommandlineParser::setParameterRestrictions | ( | String | par_name, |
list< String > & | allowed_values | ||
) |
Register the allowed values for a string-parameter.
Register the supported formats for input-/output-files.
supported_formats | supported file-formats separated by commas |
void BALL::CommandlineParser::setToolManual | ( | const String & | manual | ) |
Set the text to be displayed as mini-manual when starting the tool, containing a few sentences describing what the tool should be good for ...
|
static |
Definition at line 54 of file commandlineParser.h.
|
static |
Definition at line 53 of file commandlineParser.h.