CBICA Toolkit  1.0.0
cbicaCmdParser.h
Go to the documentation of this file.
1 /**
2 \file cbicaCmdParser.h
3 
4 \brief Declaration of the CmdParser class
5 
6 https://www.med.upenn.edu/sbia/software/// <br>
7 software@cbica.upenn.edu
8 
9 Copyright (c) 2018 University of Pennsylvania. All rights reserved. <br>
10 See COPYING file or https://www.med.upenn.edu/cbica/software-agreement.html
11 
12 */
13 #pragma once
14 
15 #include <string>
16 #include <stdio.h>
17 #include <iostream>
18 #include <iterator>
19 #include <algorithm>
20 #include <vector>
21 #include <map>
22 
23 #if defined(__GNUC__) || defined(__clang__)
24 #define DEPRECATED __attribute__((deprecated))
25 #elif defined(_MSC_VER)
26 #define DEPRECATED __declspec(deprecated)
27 #else
28 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
29 #define DEPRECATED
30 #endif
31 
32 enum Separator
33 {
34  Param, DataType, DataRange
35 };
36 
37 //! String separators corresponding to Separator
38 #if defined(__GNUC__) && (__GNUC__ < 5)
39 static const char *SeparatorStrings[] = { ":", "%", "*" };
40 #else
41 static std::vector< std::string > SeparatorStrings = { ":", "%", "*" };
42 #endif
43 
44 //! Get the Separator as a string from the enum Separator
45 static inline std::string getSeparator(int enumVal)
46 {
47  return SeparatorStrings[enumVal];
48 }
49 
50 namespace cbica
51 {
52  //! copied from cbicaUtilities to ensure CmdParser stays header-only
53  inline std::string stringReplace(const std::string &entireString,
54  const std::string &toReplace,
55  const std::string &replaceWith)
56  {
57  std::string return_string = entireString;
58  for (size_t pos = 0;; pos += replaceWith.length())
59  {
60  pos = return_string.find(toReplace, pos);
61  if (pos == std::string::npos)
62  break;
63 
64  return_string.erase(pos, toReplace.length());
65  return_string.insert(pos, replaceWith);
66  }
67  return return_string;
68  /*
69  if( entireString.length() < toReplace.length() )
70  std::cerr << "Length of string to search < length of string to replace. Please check.\n";
71 
72  return(return_string.replace(entireString.find(toReplace), toReplace.length(), replaceWith));
73  */
74  }
75 
76  //====================================== Structs that need string stuff ====================================//
77  /**
78  \struct Parameter
79 
80  \brief Holds individual parameter information
81 
82  This is a helper struct for internal usage of different functions and classes (right now, the function ReadConfigFile()
83  and the class CmdParser() use it). It is not meant to be used from a program directly.
84  All variables are self-explanatory. Currently, a maxium of five lines of description are supported.
85  */
86  struct Parameter
87  {
88  enum Type
89  {
90  FILE, DIRECTORY, STRING, INTEGER, FLOAT, BOOLEAN, NONE
91  };
92 
93  std::string laconic;
94  std::string verbose;
95  int dataType_enumCode;
96  std::string dataType_string;
97  std::string dataRange;
98  std::string descriptionLine1;
99  std::string descriptionLine2; //! defaults to blank
100  std::string descriptionLine3; //! defaults to blank
101  std::string descriptionLine4; //! defaults to blank
102  std::string descriptionLine5; //! defaults to blank
103 
104  size_t length;
105 
106  //! Constructor with five lines of description and enum_code for dataType
107  Parameter(const std::string &in_laconic, const std::string &in_verbose, const int &in_dataType, const std::string &in_dataRange,
108  const std::string &in_descriptionLine1, const std::string &in_descriptionLine2 = "", const std::string &in_descriptionLine3 = "",
109  const std::string &in_descriptionLine4 = "", const std::string &in_descriptionLine5 = "") :
110  laconic(in_laconic), verbose(in_verbose), dataType_enumCode(in_dataType), dataType_string(""), dataRange(in_dataRange),
111  descriptionLine1(in_descriptionLine1), descriptionLine2(in_descriptionLine2),
112  descriptionLine3(in_descriptionLine3), descriptionLine4(in_descriptionLine4), descriptionLine5(in_descriptionLine5)
113  {
114  laconic = cbica::stringReplace(laconic, "-", "");
115  laconic = cbica::stringReplace(laconic, "--", "");
116  verbose = cbica::stringReplace(verbose, "-", "");
117  verbose = cbica::stringReplace(verbose, "--", "");
118  length = laconic.length() + verbose.length();
119 
120  // populate dataType_string WRT dataType_enumCode
121  switch (in_dataType)
122  {
123  case FILE:
124  dataType_string = "FILE";
125  break;
126  case DIRECTORY:
127  dataType_string = "DIRECTORY";
128  break;
129  case STRING:
130  dataType_string = "STRING";
131  break;
132  case INTEGER:
133  dataType_string = "INTEGER";
134  break;
135  case FLOAT:
136  dataType_string = "FLOAT";
137  break;
138  case BOOLEAN:
139  dataType_string = "BOOL";
140  break;
141  case NONE:
142  dataType_string = "NONE";
143  break;
144  default:
145  dataType_string = "UNKNOWN";
146  break;
147  }
148  }
149 
150  //! Constructor with five lines of description and string for dataType
151  Parameter(const std::string &in_laconic, const std::string &in_verbose, const std::string &in_dataType, const std::string &in_dataRange,
152  const std::string &in_descriptionLine1, const std::string &in_descriptionLine2 = "", const std::string &in_descriptionLine3 = "",
153  const std::string &in_descriptionLine4 = "", const std::string &in_descriptionLine5 = "") :
154  laconic(in_laconic), verbose(in_verbose), dataType_enumCode(0), dataType_string(in_dataType), dataRange(in_dataRange),
155  descriptionLine1(in_descriptionLine1), descriptionLine2(in_descriptionLine2),
156  descriptionLine3(in_descriptionLine3), descriptionLine4(in_descriptionLine4), descriptionLine5(in_descriptionLine5)
157  {
158  laconic = cbica::stringReplace(laconic, "-", "");
159  laconic = cbica::stringReplace(laconic, "--", "");
160  verbose = cbica::stringReplace(verbose, "-", "");
161  verbose = cbica::stringReplace(verbose, "--", "");
162  length = laconic.length() + verbose.length();
163 
164  // populate dataType_enumCode WRT dataType_string
165  if (dataType_string == "FILE")
166  {
167  dataType_enumCode = FILE;
168  }
169  else if (dataType_string == "DIRECTORY")
170  {
171  dataType_enumCode = DIRECTORY;
172  }
173  else if (dataType_string == "STRING")
174  {
175  dataType_enumCode = STRING;
176  }
177  else if (dataType_string == "INTEGER")
178  {
179  dataType_enumCode = INTEGER;
180  }
181  else if (dataType_string == "FLOAT")
182  {
183  dataType_enumCode = FLOAT;
184  }
185  else if ((dataType_string == "BOOL") || (dataType_string == "BOOLEAN"))
186  {
187  dataType_enumCode = BOOLEAN;
188  }
189  else if (dataType_string == "NONE")
190  {
191  dataType_enumCode = NONE;
192  }
193  else
194  {
195  dataType_enumCode = -1;
196  }
197  }
198 
199  };
200 
201  /**
202  \class CmdParser
203 
204  \brief Simple command line parsing
205 
206  This is a pure c++ implementation. Executable name and project version are picked up automatically
207  from the main CMakeLists file. Only the executable name can be modified in this class.
208 
209  An example of usage is shown below:
210 
211  \verbatim
212  cbica::CmdParser parser = cbica::CmdParser(argc, argv); // OR,
213  //cbica::CmdParser parser = cbica::CmdParser(argc, argv, "exe_name"); // if a different exe_name is desired
214 
215  /// The parameters "u"/"usage", "h"/"help" and "v"/"version" are automatically added ///
216 
217  // add parameters to the variable
218  parser.addOptionalParameter("m","marvel", cbica::Parameter::INTEGER, "1 to 10", "I like The Avengers");
219  parser.addOptionalParameter("d", "dc", cbica::Parameter::FLOAT, "1.00 to 10.00", "I prefer the Justice League");
220  parser.addRequiredParameter("p", "people", cbica::Parameter::STRING, "max length = 1024", "People are always required");
221 
222  // note that there should be no spaces for either of the parameter types; they will be removed.
223 
224  /// checks for required parameters are done internally.
225 
226  std::string peopleString;
227  parser.getParameterValue("p", peopleString);
228 
229  int marvelValue = 5; // set default value
230  parser.getParameterValue("m", marvelValue);
231 
232  float dcValue = 5.15; // set default value
233  parser.getParameterValue("d", dcValue);
234 
235  doSomethingWithTheParameters( peopleString, marvelValue, dcValue );
236  \endverbatim
237  */
238  class CmdParser
239  {
240  public:
241  /**
242  \brief The Constructor
243 
244  \param argc The "argc" from executable
245  \param argv The "argv" from executable
246  \param exe_name Name of the executable, defaults to picking up from cbica::getExecutableName()
247  */
248  explicit CmdParser(const int argc, char **argv, const std::string &exe_name = "");
249 
250  /**
251  \brief The Constructor
252 
253  \param argc The "argc" from executable
254  \param argv The "argv" from executable
255  \param exe_name Name of the executable, defaults to picking up from cbica::getExecutableName()
256  */
257  explicit CmdParser(const int argc, const char **argv, const std::string &exe_name = "");
258 
259  /**
260  \brief The Destructor
261  */
262  virtual ~CmdParser();
263 
264  /**
265  \brief Set a custom executable name
266  */
267  void setExeName(const std::string exeName){ m_exeName = exeName; };
268 
269  /**
270  \get the executable name
271  */
272  std::string getExeName() { return m_exeName; };
273 
274  /**
275  \brief Adding parameters: defaults to optional parameters
276 
277  As a standard, neither the laconic nor verbose parameters should have any '-' in the constructor.
278 
279  \param laconic The laconic variant
280  \param verbose The verbose variant
281  \param expectedDataType The data type expected for this parameter
282  \param dataRange The range of data expected for this parameter
283  \param description_line1 The first line of description for parameter
284  \param description_line2 The second line of description for parameter, defaults to a blank string
285  \param description_line3 The third line of description for parameter, defaults to a blank string
286  \param description_line4 The fourth line of description for parameter, defaults to a blank string
287  \param description_line5 The fifth line of description for parameter, defaults to a blank string
288  */
289  void addParameter(const std::string &laconic, const std::string &verbose, const int &expectedDataType, const std::string &dataRange,
290  const std::string &description_line1, const std::string &description_line2 = "", const std::string &description_line3 = "",
291  const std::string &description_line4 = "", const std::string &description_line5 = "");
292 
293  /**
294  \brief Adding Optional parameters
295 
296  As a standard, neither the laconic nor verbose parameters should have any '-' in the constructor.
297 
298  \param laconic The laconic variant
299  \param verbose The verbose variant
300  \param expectedDataType The data type expected for this parameter
301  \param dataRange The range of data expected for this parameter
302  \param description_line1 The first line of description for parameter
303  \param description_line2 The second line of description for parameter, defaults to a blank string
304  \param description_line3 The third line of description for parameter, defaults to a blank string
305  \param description_line4 The fourth line of description for parameter, defaults to a blank string
306  \param description_line5 The fifth line of description for parameter, defaults to a blank string
307  */
308  void addOptionalParameter(const std::string &laconic, const std::string &verbose, const int &expectedDataType, const std::string &dataRange,
309  const std::string &description_line1, const std::string &description_line2 = "", const std::string &description_line3 = "",
310  const std::string &description_line4 = "", const std::string &description_line5 = "");
311 
312  /**
313  \brief Adding Required parameters
314 
315  As a standard, neither the laconic nor verbose parameters should have any '-' in the constructor.
316 
317  \param laconic The laconic variant
318  \param verbose The verbose variant
319  \param expectedDataType The data type expected for this parameter
320  \param dataRange The range of data expected for this parameter
321  \param description_line1 The first line of description for parameter
322  \param description_line2 The second line of description for parameter, defaults to a blank string
323  \param description_line3 The third line of description for parameter, defaults to a blank string
324  \param description_line4 The fourth line of description for parameter, defaults to a blank string
325  \param description_line5 The fifth line of description for parameter, defaults to a blank string
326  */
327  void addRequiredParameter(const std::string &laconic, const std::string &verbose, const int &expectedDataType, const std::string &dataRange,
328  const std::string &description_line1, const std::string &description_line2 = "", const std::string &description_line3 = "",
329  const std::string &description_line4 = "", const std::string &description_line5 = "");
330 
331  /**
332  \brief Display the usage
333  */
334  void echoUsage();
335 
336  /**
337  \brief Display verbose usage
338  */
339  void echoHelp();
340 
341  /**
342  \brief Display the version details
343  */
344  void echoVersion();
345 
346  /**
347  \brief Check parameters WITHOUT hyphens
348 
349  Checks for both laconic and verbose variants of the specified parameter.
350 
351  \param execParamToCheck Which parameter to check
352  \param position Position of parameter in argv else -1
353  \return True if parameter found else False
354  */
355  bool compareParameter(const std::string &execParamToCheck, int &position, bool automaticEcho = true);
356 
357  /**
358  \brief Check parameters WITHOUT hyphens
359 
360  Checks for both laconic and verbose variants of the specified parameter. Can be used to see if the parameter is present or not.
361 
362  \param execParamToCheck Which parameter to check
363  \return True if parameter found else False
364  */
365  bool compareParameter(const std::string &execParamToCheck, bool automaticEcho = true);
366 
367  /**
368  \brief Check if supplied parameter is present in the argument list
369 
370  Checks for both laconic and verbose variants of the specified parameter. Uses compareParameter() internally.
371 
372  \param execParamToCheck Which parameter to check
373  \return True if parameter found else False
374  */
375  bool isPresent(const std::string &execParamToCheck, bool automaticEcho = true);
376 
377  /**
378  \brief Get the description analogous with the parameter
379 
380  Can search using both laconic and verbose parameters.
381 
382  \param parameter Parameter whose description is requested
383  \param "NewLine Return with "\n" between description lines if true, defaults to space between lines
384  \return Description of parameter
385  */
386  std::string getDescription(const std::string &execParamToCheck, bool NewLine);
387 
388  /**
389  \brief Get the data type analogous with the parameter
390 
391  Can search using both laconic and verbose parameters.
392 
393  \param parameter Parameter whose description is requested
394  \return Description of parameter as string
395  */
396  std::string getDataTypeAsString(const std::string &execParamToCheck);
397 
398  /**
399  \brief Get the data type analogous with the parameter
400 
401  Can search using both laconic and verbose parameters.
402 
403  \param parameter Parameter whose description is requested
404  \return Description of parameter as Enum Code (Parameter::Type)
405  */
406  int getDataTypeAsEnumCode(const std::string &execParamToCheck);
407 
408  /**
409  \brief Write the parser configuration as a JSON file
410  */
411  //void writeJSONFile(const std::string & dirName);
412 
413  /**
414  \brief Write the configuration file for the executable for use in the common GUI framework
415 
416  The generated config file is always named 'EXE_NAME.txt'.
417 
418  \param dirName The full path of the directory to save the file; defaults to directory specified in cbica::makeTempDir()
419  */
420  void writeConfigFile(const std::string &dirName = "");
421 
422  /**
423  \brief Reads a pre-written configuration file using CmdParser::WriteConfigFile()
424 
425  \param inputConfigFile Full path to the configuration file which needs to be read
426  \return Vector of the Parameter structure where laconic paramter is always empty for all variables
427  */
428  static std::vector< Parameter > readConfigFile(const std::string &inputConfigFile, bool getDescription = true);
429 
430  /**
431  \brief Gives a brief example of how to use the executable
432 
433  This should not contain any references to the executable name (it is automatically picked up).
434  It should start directly with the parameters to be put in.
435 
436  \param usageOfExe A string which would correspond to the command line usage AFTER the executable has been called
437  */
438  DEPRECATED void exampleUsage(const std::string &usageOfExe);
439 
440  /**
441  \brief Gives a brief example of how to use the executable
442 
443  This should not contain any references to the executable name (it is automatically picked up).
444  It should start directly with the parameters to be put in.
445 
446  \param commandExcludingExeName A string which would correspond to the command line usage AFTER the executable has been called
447  \param descriptionOfCommand A string which would correspond to what the command is expected to do
448  */
449  void addExampleUsage(const std::string &commandExcludingExeName, const std::string &descriptionOfCommand);
450 
451  /**
452  \brief Adds descrition for the application for which the class is being initialized
453  */
454  void addApplicationDescription(const std::string &description);
455 
456  /**
457  \brief Writes out a CWL specification file from cmd parser
458 
459  This should be invoked everytime the cmd parser is called for an application.
460 
461  \param dirName Full directory path to where the CWL spec will be produced
462  \param workflowName For more advanced CWL workflows
463  \param overwriteFile If the current file should be overwritten or not
464  */
465  void writeCWLFile(const std::string & dirName, bool overwriteFile);
466 
467  /*
468  \brief Gets the command line string with all the parameters from input yml file
469 
470  This needs a input yml file to parse parameter values to CWL specs
471 
472  \param dirName Full directory path to the input yml file
473 
474  */
475  std::string GetCommandFromCWL(const std::string &inpDir, const std::string & cwlDir);
476 
477  /*
478  \brief Reads a CWL spec file and creates a the command line tool for the application
479 
480  This reads a CWL file and populates the cmd parser
481 
482  \param path_to_config_file Path to the CWL spec file
483 
484  \param getDescription This is a flag incase we want to run the CWL spec file with default values
485 
486  */
487  void readCWLFile(const std::string & path_to_config_file, bool getDescription);
488 
489  /*
490  \brief Creates a YAML node for the given root node.
491 
492  This creates a new node
493 
494  \param nodeString Name of the node
495 
496  \param rootNode Parent node of the new node to be created
497 
498  */
499  void createNode(const std::string & nodeString);
500 
501  /*
502  \brief Deletes a YAML node inside the root node.
503 
504  This creates a new node
505 
506  \param nodeString Name of the node
507 
508  \param parent Parent node of the new node to be created
509 
510  */
511  void deleteNode(const std::string & nodeString);
512 
513  /*
514  \brief Adds an input parameter inside input node.
515 
516  This creates a new input parameter
517 
518  \param param Name of the parameter to be added
519 
520  \param rootNode Root Node of the CWL spec file
521 
522  */
523  void addInputs(const std::string & param);
524 
525  /*
526  \brief Adds an output field.
527 
528  This creates a new output field
529 
530  \param param Name of the parameter to be added
531 
532  \param rootNode Root Node of the CWL spec file
533 
534  */
535  void addOutputs(const std::string & param);
536 
537  /*
538  \brief Checks if default value is specified for a parameter.
539 
540  This returns the default value of parameter if exists
541 
542  \param param Name of the parameter to be checked
543 
544  \param input INPUT node of CWL spec
545 
546  */
547  std::string checkDefault(const std::string & param);
548 
549  /*
550  Invokes cwl-runner tool from the command line tool with given command
551 
552  This invokes the cwl runner according to the flag for default values
553 
554  \param cwl_spec_path Path to the CWL spec file
555  \param cwl_input_path Path to the input yml file. Empty string if doesn't exist
556  \param getDefaultFlag execute default or not default boolean
557 
558  */
559  void cwlrunner(const std::string & cwl_spec_path, const std::string & cwl_input_path, bool getDefaultFlag);
560 
561  /**
562  \brief Get the laconic value from verbose
563 
564  Searches using the verbose value.
565 
566  \param execParamToCheck The verbose variant of the parameter
567 
568  */
569  std::string getLaconic(const std::string &execParamToCheck);
570 
571  /**
572  \brief Get the value of the parameter
573 
574  Can search using both laconic and verbose parameters.
575 
576  \param execParamToCheck The laconic or verbose variant of the parameter
577  \param parameterValue The return value of the parameter as bool
578  */
579  void getParameterValue(const std::string &execParamToCheck, bool &parameterValue);
580 
581  /**
582  \brief Get the value of the parameter
583 
584  Can search using both laconic and verbose parameters.
585 
586  \param execParamToCheck The laconic or verbose variant of the parameter
587  \param parameterValue The return value of the parameter as int
588  */
589  void getParameterValue(const std::string &execParamToCheck, int &parameterValue);
590 
591  /**
592  \brief Get the value of the parameter
593 
594  Can search using both laconic and verbose parameters.
595 
596  \param execParamToCheck The laconic or verbose variant of the parameter
597  \param parameterValue The return value of the parameter as size_t
598  */
599  void getParameterValue(const std::string &execParamToCheck, size_t &parameterValue);
600 
601  /**
602  \brief Get the value of the parameter
603 
604  Can search using both laconic and verbose parameters.
605 
606  \param execParamToCheck The laconic or verbose variant of the parameter
607  \param parameterValue The return value of the parameter as float
608  */
609  void getParameterValue(const std::string &execParamToCheck, float &parameterValue);
610 
611  /**
612  \brief Get the value of the parameter
613 
614  Can search using both laconic and verbose parameters.
615 
616  \param execParamToCheck The laconic or verbose variant of the parameter
617  \param parameterValue The return value of the parameter as std::string (valid for Parameter::Type::FILE, Parameter::Type::DIRECTORY, Parameter::Type::STRING)
618  */
619  void getParameterValue(const std::string &execParamToCheck, std::string &parameterValue);
620 
621  //! This function ensures that argc < 2 isn't checked
622  void ignoreArgc1()
623  {
624  argc1ignore = true;
625  }
626 
627  private:
628 
629  //! Executable name
630  std::string m_exeName;
631  //! Executable path
632  std::string m_exePath;
633  //! Version
634  std::string m_version;
635  //! Example of how to use the executable in question
636  std::string m_exampleOfUsage;
637  //! Description of the application - intended to give a short overview of what the user should expect
638  std::string m_description;
639  //! CMD variable, used to ensure that 'const' based variables are taken into consideration
640  int m_argc;
641  //! CMD variable, used to ensure that 'const' based variables are taken into consideration
642  std::vector< std::string > m_argv;
643  //! Collection of required and optional parameters
644  std::vector< Parameter > m_requiredParameters, m_optionalParameters;
645  //! Max length of parameters for echoUsage()
646  size_t m_maxLength;
647  //! Flag to toggle check for maximum overall length
648  bool checkMaxLen;
649  //! Flag to check for requested help/usage
650  bool helpRequested;
651  //! Flag to check for requested help/usage
652  bool firstRun;
653  //! check argc stuff internally
654  bool argc1ignore;
655  //! Initialize the class
656  inline void initializeClass(int &input_argc, std::vector< std::string > &input_argv, const std::string &input_exeName = "");
657  //! Get max length
658  inline void getMaxLength();
659  //! Internal function to check for verbose parameter
660  inline void verbose_check(std::string &input_string);
661  //! Internal function to write vector of parameters
662  inline void writeParameters(const std::vector< Parameter > &inputParameters, bool verbose);
663  //! Logs the CWL that is passed through cwl-runner
664  void logCWL(const std::string &inpFileName, const std::string &cwlFileName);
665 
666  //! application usage examples and their respective descriptions
667  std::vector< std::pair< std::string, std::string > > m_exampleUsageAndDescription;
668 
669 
670  size_t m_maxLaconicLength, //! maximum length of laconic parameters
671  m_minVerboseLength,
672  m_maxVerboseLength; //! maximum length of verbose parameters
673 
674  };
675 }
Parameter(const std::string &in_laconic, const std::string &in_verbose, const std::string &in_dataType, const std::string &in_dataRange, const std::string &in_descriptionLine1, const std::string &in_descriptionLine2="", const std::string &in_descriptionLine3="", const std::string &in_descriptionLine4="", const std::string &in_descriptionLine5="")
Constructor with five lines of description and string for dataType.
Definition: cbicaCmdParser.h:151
Parameter(const std::string &in_laconic, const std::string &in_verbose, const int &in_dataType, const std::string &in_dataRange, const std::string &in_descriptionLine1, const std::string &in_descriptionLine2="", const std::string &in_descriptionLine3="", const std::string &in_descriptionLine4="", const std::string &in_descriptionLine5="")
Constructor with five lines of description and enum_code for dataType.
Definition: cbicaCmdParser.h:107
bool compareParameter(const std::string &execParamToCheck, int &position, bool automaticEcho=true)
Check parameters WITHOUT hyphens.
CmdParser(const int argc, char **argv, const std::string &exe_name="")
The Constructor.
Holds individual parameter information.
Definition: cbicaCmdParser.h:86
std::string getExeName()
\get the executable name
Definition: cbicaCmdParser.h:272
void writeConfigFile(const std::string &dirName="")
Write the parser configuration as a JSON file.
virtual ~CmdParser()
The Destructor.
void addExampleUsage(const std::string &commandExcludingExeName, const std::string &descriptionOfCommand)
Gives a brief example of how to use the executable.
void addApplicationDescription(const std::string &description)
Adds descrition for the application for which the class is being initialized.
size_t length
defaults to blank
Definition: cbicaCmdParser.h:104
std::string getDescription(const std::string &execParamToCheck, bool NewLine)
Get the description analogous with the parameter.
void setExeName(const std::string exeName)
Set a custom executable name.
Definition: cbicaCmdParser.h:267
std::string descriptionLine5
defaults to blank
Definition: cbicaCmdParser.h:102
std::string descriptionLine3
defaults to blank
Definition: cbicaCmdParser.h:100
void echoVersion()
Display the version details.
void ignoreArgc1()
This function ensures that argc < 2 isn't checked.
Definition: cbicaCmdParser.h:622
void addParameter(const std::string &laconic, const std::string &verbose, const int &expectedDataType, const std::string &dataRange, const std::string &description_line1, const std::string &description_line2="", const std::string &description_line3="", const std::string &description_line4="", const std::string &description_line5="")
Adding parameters: defaults to optional parameters.
void addOptionalParameter(const std::string &laconic, const std::string &verbose, const int &expectedDataType, const std::string &dataRange, const std::string &description_line1, const std::string &description_line2="", const std::string &description_line3="", const std::string &description_line4="", const std::string &description_line5="")
Adding Optional parameters.
void writeCWLFile(const std::string &dirName, bool overwriteFile)
Writes out a CWL specification file from cmd parser.
DEPRECATED void exampleUsage(const std::string &usageOfExe)
Gives a brief example of how to use the executable.
void echoHelp()
Display verbose usage.
static std::vector< Parameter > readConfigFile(const std::string &inputConfigFile, bool getDescription=true)
Reads a pre-written configuration file using CmdParser::WriteConfigFile()
int getDataTypeAsEnumCode(const std::string &execParamToCheck)
Get the data type analogous with the parameter.
void addRequiredParameter(const std::string &laconic, const std::string &verbose, const int &expectedDataType, const std::string &dataRange, const std::string &description_line1, const std::string &description_line2="", const std::string &description_line3="", const std::string &description_line4="", const std::string &description_line5="")
Adding Required parameters.
void echoUsage()
Display the usage.
bool isPresent(const std::string &execParamToCheck, bool automaticEcho=true)
Check if supplied parameter is present in the argument list.
std::string getLaconic(const std::string &execParamToCheck)
Get the laconic value from verbose.
std::string stringReplace(const std::string &entireString, const std::string &toReplace, const std::string &replaceWith)
copied from cbicaUtilities to ensure CmdParser stays header-only
Definition: cbicaCmdParser.h:53
std::string descriptionLine4
defaults to blank
Definition: cbicaCmdParser.h:101
Simple command line parsing.
Definition: cbicaCmdParser.h:238
std::string getDataTypeAsString(const std::string &execParamToCheck)
Get the data type analogous with the parameter.
void getParameterValue(const std::string &execParamToCheck, bool &parameterValue)
Get the value of the parameter.