diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index d35e9b9d2..595c40a40 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -146,6 +146,9 @@ class App { /// This is a function that runs when all processing has completed std::function final_callback_{}; + /// This is a function tat runs after all standard requirement checks havv been processed + std::function require_callback_{}; + ///@} /// @name Options ///@{ @@ -376,6 +379,13 @@ class App { return this; } + /// Set a callback to execute after all standard requirement checks have been processed + /// + App *require_callback(std::function req_callback) { + require_callback_ = std::move(req_callback); + return this; + } + /// Set a name for the app (empty will use parser to set the name) App *name(std::string app_name = ""); diff --git a/include/CLI/impl/App_inl.hpp b/include/CLI/impl/App_inl.hpp index 614805dde..244a37871 100644 --- a/include/CLI/impl/App_inl.hpp +++ b/include/CLI/impl/App_inl.hpp @@ -1410,6 +1410,10 @@ CLI11_INLINE void App::_process_requirements() { throw(CLI::RequiredError(sub->get_display_name())); } } + + if (require_callback_) { + require_callback_(); + } } CLI11_INLINE void App::_process() {