@@ -200,7 +200,7 @@ class Option : public OptionBase<Option> {
200200 std::vector<std::function<std::string(std::string &)>> validators_;
201201
202202 // / A list of options that are required with this option
203- std::set<Option *> requires_ ;
203+ std::set<Option *> needs_ ;
204204
205205 // / A list of options that are excluded with this option
206206 std::set<Option *> excludes_;
@@ -322,7 +322,7 @@ class Option : public OptionBase<Option> {
322322
323323 // / Sets required options
324324 Option *needs (Option *opt) {
325- auto tup = requires_ .insert (opt);
325+ auto tup = needs_ .insert (opt);
326326 if (!tup.second )
327327 throw OptionAlreadyAdded::Requires (get_name (), opt->get_name ());
328328 return this ;
@@ -342,6 +342,18 @@ class Option : public OptionBase<Option> {
342342 return needs (opt1, args...);
343343 }
344344
345+ // / Remove needs link from an option. Returns true if the option really was in the needs list.
346+ bool remove_needs (Option *opt) {
347+ auto iterator = std::find (std::begin (needs_), std::end (needs_), opt);
348+
349+ if (iterator != std::end (needs_)) {
350+ needs_.erase (iterator);
351+ return true ;
352+ } else {
353+ return false ;
354+ }
355+ }
356+
345357 // / Sets excluded options
346358 Option *excludes (Option *opt) {
347359 excludes_.insert (opt);
@@ -369,6 +381,18 @@ class Option : public OptionBase<Option> {
369381 return excludes (opt1, args...);
370382 }
371383
384+ // / Remove needs link from an option. Returns true if the option really was in the needs list.
385+ bool remove_excludes (Option *opt) {
386+ auto iterator = std::find (std::begin (excludes_), std::end (excludes_), opt);
387+
388+ if (iterator != std::end (excludes_)) {
389+ excludes_.erase (iterator);
390+ return true ;
391+ } else {
392+ return false ;
393+ }
394+ }
395+
372396 // / Sets environment variable to read if no option given
373397 Option *envname (std::string name) {
374398 envname_ = name;
@@ -418,7 +442,7 @@ class Option : public OptionBase<Option> {
418442 std::string get_envname () const { return envname_; }
419443
420444 // / The set of options needed
421- std::set<Option *> get_needs () const { return requires_ ; }
445+ std::set<Option *> get_needs () const { return needs_ ; }
422446
423447 // / The set of options excluded
424448 std::set<Option *> get_excludes () const { return excludes_; }
0 commit comments