Loading...
Searching...
No Matches
BALL::CommandlineParser Class Reference

`#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 | registerMandatoryIntegerParameter (const String &name, const String &description)
void | registerMandatoryIntegerListParameter (const String &name, const String &description)
void | registerMandatoryDoubleParameter (const String &name, const String &description)
void | registerMandatoryDoubleListParameter (const String &name, const String &description)
void | registerMandatoryStringParameter (const String &name, const String &description)
void | registerMandatoryStringListParameter (const String &name, const String &description)
void | registerMandatoryInputFile (const String &name, const String &description)
void | registerMandatoryOutputFile (const String &name, const String &description)
void | registerMandatoryInputFileList (const String &name, const String &description)
void | registerMandatoryOutputFileList (const String &name, const String &description)
void | registerMandatoryGalaxyOutputFolder (const String &name, const String &description)
void | registerMandatoryGalaxyOutputId (const String &name, const String &description)
void | registerOptionalIntegerParameter (const String &name, const String &description, int default_value=0)
void | registerOptionalIntegerListParameter (const String &name, const String &description, const std::vector< int > &default_values=vector< int >())
void | registerOptionalDoubleParameter (const String &name, const String &description, double default_value=0.0)
void | registerOptionalDoubleListParameter (const String &name, const String &description, const std::vector< double > &default_values=vector< double >())
void | registerOptionalStringParameter (const String &name, const String &description, const String &default_value="")
void | registerOptionalStringListParameter (const String &name, const String &description, const std::vector< String > &default_values=vector< String >())
void | registerOptionalInputFile (const String &name, const String &description, const String &default_value="")
void | registerOptionalOutputFile (const String &name, const String &description, const String &default_value="")
void | registerOptionalInputFileList (const String &name, const String &description, const std::vector< String > &default_values=vector< String >())
void | registerOptionalOutputFileList (const String &name, const String &description, const std::vector< String > &default_values=vector< String >())
void | registerOptionalGalaxyOutputFolder (const String &name, const String &description, const String &default_value="")
void | registerOptionalGalaxyOutputId (const String &name, const String &description, const String &default_value="")
void | registerFlag (String name, String description, bool default_gui_value=false, bool hidden=false)
void | registerAdvancedParameters (Options &options)
void | setParameterAsAdvanced (String name)
void | setParameterAsHidden (String name)
void | setParameterRestrictions (String category, String par_name, double min_value, double max_value)
void | setParameterRestrictions (String par_name, double min_value, double max_value)
void | setParameterRestrictions (String category, String par_name, int min_value, int max_value)
void | setParameterRestrictions (String par_name, int min_value, int max_value)
void | setParameterRestrictions (String category, String par_name, list< String > &allowed_values)
void | setParameterRestrictions (String par_name, list< String > &allowed_values)
void | setSupportedFormats (String category, String par_name, String supported_formats)
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 > &parameter_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

## Detailed Description

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 38 of file commandlineParser.h.

## Constructor & Destructor Documentation

## CommandlineParser()

BALL::CommandlineParser::CommandlineParser | ( | String | tool_name,
|  | String | tool_description,
|  | String | tool_version,
|  | String | build_date,
|  | String | category = "" )

## Member Function Documentation

## copyAdvancedParametersToOptions()

void BALL::CommandlineParser::copyAdvancedParametersToOptions | ( | Options & | options | ) |

Copies names and values of all advanced parameters to the given Options object.

## get()

const String & BALL::CommandlineParser::get | ( | String | name | ) |

Returns the value for a given parameter name.
Example: For "-o outfile.sdf", CommandlineParser::get("o") will return "outfile.sdf".

## getList()

const list< String > & BALL::CommandlineParser::getList | ( | String | name | ) |

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'.

## getStartCommand()

const String & BALL::CommandlineParser::getStartCommand | ( |  | ) |

Get the exact command with which the tool was started on the command-line.

## getStartTime()

const String & BALL::CommandlineParser::getStartTime | ( |  | ) |

## has()

bool BALL::CommandlineParser::has | ( | String | name | ) |

Find out whether a the parameter or flag has been specified on the command-line.

## parse()

void BALL::CommandlineParser::parse | ( | int | argc,
|  | char * | argv[] )

Parse all parameters found in the command line

## printHelp()

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.

## printToolInfo()

void BALL::CommandlineParser::printToolInfo | ( |  | ) |

## registerAdvancedParameters()

void BALL::CommandlineParser::registerAdvancedParameters | ( | Options & | options | ) |

## registerFlag()

void BALL::CommandlineParser::registerFlag | ( | String | name,
|  | String | description,
|  | bool | default_gui_value = false,
|  | bool | hidden = false )

## registerMandatoryDoubleListParameter()

void BALL::CommandlineParser::registerMandatoryDoubleListParameter | ( | const String & | name,
|  | const String & | description )

## registerMandatoryDoubleParameter()

void BALL::CommandlineParser::registerMandatoryDoubleParameter | ( | const String & | name,
|  | const String & | description )

## registerMandatoryGalaxyOutputFolder()

void BALL::CommandlineParser::registerMandatoryGalaxyOutputFolder | ( | const String & | name,
|  | const String & | description )

## registerMandatoryGalaxyOutputId()

void BALL::CommandlineParser::registerMandatoryGalaxyOutputId | ( | const String & | name,
|  | const String & | description )

## registerMandatoryInputFile()

void BALL::CommandlineParser::registerMandatoryInputFile | ( | const String & | name,
|  | const String & | description )

## registerMandatoryInputFileList()

void BALL::CommandlineParser::registerMandatoryInputFileList | ( | const String & | name,
|  | const String & | description )

## registerMandatoryIntegerListParameter()

void BALL::CommandlineParser::registerMandatoryIntegerListParameter | ( | const String & | name,
|  | const String & | description )

## registerMandatoryIntegerParameter()

void BALL::CommandlineParser::registerMandatoryIntegerParameter | ( | const String & | name,
|  | const String & | description )

## registerMandatoryOutputFile()

void BALL::CommandlineParser::registerMandatoryOutputFile | ( | const String & | name,
|  | const String & | description )

## registerMandatoryOutputFileList()

void BALL::CommandlineParser::registerMandatoryOutputFileList | ( | const String & | name,
|  | const String & | description )

## registerMandatoryStringListParameter()

void BALL::CommandlineParser::registerMandatoryStringListParameter | ( | const String & | name,
|  | const String & | description )

## registerMandatoryStringParameter()

void BALL::CommandlineParser::registerMandatoryStringParameter | ( | const String & | name,
|  | const String & | description )

## registerOptionalDoubleListParameter()

void BALL::CommandlineParser::registerOptionalDoubleListParameter | ( | const String & | name,
|  | const String & | description,
|  | const std::vector< double > & | default_values = vector< double >() )

## registerOptionalDoubleParameter()

void BALL::CommandlineParser::registerOptionalDoubleParameter | ( | const String & | name,
|  | const String & | description,
|  | double | default_value = 0.0 )

## registerOptionalGalaxyOutputFolder()

void BALL::CommandlineParser::registerOptionalGalaxyOutputFolder | ( | const String & | name,
|  | const String & | description,
|  | const String & | default_value = "" )

## registerOptionalGalaxyOutputId()

void BALL::CommandlineParser::registerOptionalGalaxyOutputId | ( | const String & | name,
|  | const String & | description,
|  | const String & | default_value = "" )

## registerOptionalInputFile()

void BALL::CommandlineParser::registerOptionalInputFile | ( | const String & | name,
|  | const String & | description,
|  | const String & | default_value = "" )

## registerOptionalInputFileList()

void BALL::CommandlineParser::registerOptionalInputFileList | ( | const String & | name,
|  | const String & | description,
|  | const std::vector< String > & | default_values = vector< String >() )

## registerOptionalIntegerListParameter()

void BALL::CommandlineParser::registerOptionalIntegerListParameter | ( | const String & | name,
|  | const String & | description,
|  | const std::vector< int > & | default_values = vector< int >() )

## registerOptionalIntegerParameter()

void BALL::CommandlineParser::registerOptionalIntegerParameter | ( | const String & | name,
|  | const String & | description,
|  | int | default_value = 0 )

## registerOptionalOutputFile()

void BALL::CommandlineParser::registerOptionalOutputFile | ( | const String & | name,
|  | const String & | description,
|  | const String & | default_value = "" )

## registerOptionalOutputFileList()

void BALL::CommandlineParser::registerOptionalOutputFileList | ( | const String & | name,
|  | const String & | description,
|  | const std::vector< String > & | default_values = vector< String >() )

## registerOptionalStringListParameter()

void BALL::CommandlineParser::registerOptionalStringListParameter | ( | const String & | name,
|  | const String & | description,
|  | const std::vector< String > & | default_values = vector< String >() )

## registerOptionalStringParameter()

void BALL::CommandlineParser::registerOptionalStringParameter | ( | const String & | name,
|  | const String & | description,
|  | const String & | default_value = "" )

## setParameterAsAdvanced()

void BALL::CommandlineParser::setParameterAsAdvanced | ( | String | name | ) |

## setParameterAsHidden()

void BALL::CommandlineParser::setParameterAsHidden | ( | String | name | ) |

## setParameterRestrictions() [1/6]

void BALL::CommandlineParser::setParameterRestrictions | ( | String | category,
|  | String | par_name,
|  | double | min_value,
|  | double | max_value )

Register the minimal and maximal allowed value for a floating-point numerical parameter.

## setParameterRestrictions() [2/6]

void BALL::CommandlineParser::setParameterRestrictions | ( | String | category,
|  | String | par_name,
|  | int | min_value,
|  | int | max_value )

Register the minimal and maximal allowed value for an integer numerical parameter.

## setParameterRestrictions() [3/6]

void BALL::CommandlineParser::setParameterRestrictions | ( | String | category,
|  | String | par_name,
|  | list< String > & | allowed_values )

Register the allowed values for a string-parameter.

## setParameterRestrictions() [4/6]

void BALL::CommandlineParser::setParameterRestrictions | ( | String | par_name,
|  | double | min_value,
|  | double | max_value )

## setParameterRestrictions() [5/6]

void BALL::CommandlineParser::setParameterRestrictions | ( | String | par_name,
|  | int | min_value,
|  | int | max_value )

## setParameterRestrictions() [6/6]

void BALL::CommandlineParser::setParameterRestrictions | ( | String | par_name,
|  | list< String > & | allowed_values )

## setSupportedFormats() [1/2]

void BALL::CommandlineParser::setSupportedFormats | ( | String | category,
|  | String | par_name,
|  | String | supported_formats )

Register the supported formats for input-/output-files.

Parameters

  supported_formats | supported file-formats separated by commas

## setSupportedFormats() [2/2]

void BALL::CommandlineParser::setSupportedFormats | ( | String | par_name,
|  | String | supported_formats )

## setToolManual()

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 ...

## Member Data Documentation

## EMTPY_LIST

const list<String> BALL::CommandlineParser::EMTPY_LIST

static

Definition at line 47 of file commandlineParser.h.

## NOT_FOUND

const String BALL::CommandlineParser::NOT_FOUND

static

Definition at line 46 of file commandlineParser.h.