Removes an option from the App. Takes an option pointer. Returns true if found and removed.
| 5446 | |
| 5447 | /// Removes an option from the App. Takes an option pointer. Returns true if found and removed. |
| 5448 | bool remove_option(Option *opt) { |
| 5449 | // Make sure no links exist |
| 5450 | for (Option_p &op : options_) { |
| 5451 | op->remove_needs(opt); |
| 5452 | op->remove_excludes(opt); |
| 5453 | } |
| 5454 | |
| 5455 | if (help_ptr_ == opt) help_ptr_ = nullptr; |
| 5456 | if (help_all_ptr_ == opt) help_all_ptr_ = nullptr; |
| 5457 | |
| 5458 | auto iterator = |
| 5459 | std::find_if(std::begin(options_), std::end(options_), [opt](const Option_p &v) { return v.get() == opt; }); |
| 5460 | if (iterator != std::end(options_)) { |
| 5461 | options_.erase(iterator); |
| 5462 | return true; |
| 5463 | } |
| 5464 | return false; |
| 5465 | } |
| 5466 | |
| 5467 | /// creates an option group as part of the given app |
| 5468 | template <typename T = Option_group> |
no test coverage detected