Skip to content
Snippets Groups Projects
Commit fd7c713e authored by Christian Beckmann's avatar Christian Beckmann
Browse files

Added functionality to make options invisible (i.e. not appear in a

usage line)
parent de1dff08
No related branches found
No related tags found
No related merge requests found
...@@ -43,12 +43,27 @@ namespace Utilities { ...@@ -43,12 +43,27 @@ namespace Utilities {
*/ */
BaseOption(const string& k, const string& ht, bool c, ArgFlag f): BaseOption(const string& k, const string& ht, bool c, ArgFlag f):
key_(k), help_text_(ht), arg_flag_(f), key_(k), help_text_(ht), arg_flag_(f),
unset_(true), compulsory_(c) {} unset_(true), compulsory_(c), visible_(true) {}
/**
@param k comma seperated list of key aliases
@param ht the help text to be printed for this option
@param c if true then this option is compulsory
@param f one of no_argument, requires_argument, optional_argument
@param v true or false -- display the option in usage
to indicate what arguments should be supplied
*/
BaseOption(const string& k, const string& ht, bool c, ArgFlag f, bool v):
key_(k), help_text_(ht), arg_flag_(f),
unset_(true), compulsory_(c), visible_(v) {}
/** /**
@return true if the option is compulsory @return true if the option is compulsory
*/ */
bool compulsory() { return compulsory_; } bool compulsory() { return compulsory_; }
/**
@return true if the option should be visible
*/
bool visible() { return visible_; }
/** /**
@return true if the option requires an argument @return true if the option requires an argument
*/ */
...@@ -97,7 +112,7 @@ namespace Utilities { ...@@ -97,7 +112,7 @@ namespace Utilities {
ArgFlag arg_flag_; ArgFlag arg_flag_;
protected: protected:
bool unset_, compulsory_; bool unset_, compulsory_, visible_;
}; };
ostream& operator<<(ostream &os, const BaseOption& o); ostream& operator<<(ostream &os, const BaseOption& o);
...@@ -122,6 +137,16 @@ namespace Utilities { ...@@ -122,6 +137,16 @@ namespace Utilities {
Option(const string& k, const T& v, const string& ht, Option(const string& k, const T& v, const string& ht,
bool c, ArgFlag f = no_argument): bool c, ArgFlag f = no_argument):
BaseOption(k, ht, c, f), default_(v), value_(v) {} BaseOption(k, ht, c, f), default_(v), value_(v) {}
/**
@param k Comma seperated list of key aliases
@param v Default value for this option
@param ht Help text to be printed when outputting usage
@param c If true then this option is compulsory
@param f This options argument requirements
*/
Option(const string& k, const T& v, const string& ht,
bool c, ArgFlag f, bool vis):
BaseOption(k, ht, c, f, vis), default_(v), value_(v) {}
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment