Add should_exit support for v2 parsers

- Add should_exit support to v2 platform parsers
- Introduce macros.h and integrate trait hints
- Wire CMake packaging with config, version, and install dirs
- Update parser traits to include validation hooks and fixes
This commit is contained in:
2026-04-20 18:43:44 +04:00
parent 5e1f203713
commit 2d018e94d5
16 changed files with 245 additions and 86 deletions

View File

@@ -3,7 +3,6 @@
#include <argument_parser.hpp>
#include <array>
#include <cstdlib>
#include <fake_parser.hpp>
#include <initializer_list>
#include <memory>
#include <optional>
@@ -91,12 +90,14 @@ namespace argument_parser::v2 {
using argument_parser::base_parser::current_conventions;
using argument_parser::base_parser::reset_current_conventions;
void prepare_help_flag() {
void prepare_help_flag(bool should_exit = true) {
add_argument({{flags::ShortArgument, "h"},
{flags::LongArgument, "help"},
{flags::Action, helpers::make_non_parametered_action([this]() {
{flags::Action, helpers::make_non_parametered_action([this, should_exit]() {
this->display_help(this->current_conventions());
std::exit(0);
if (should_exit) {
std::exit(0);
}
})},
{flags::HelpText, "Prints this help text."}});
}