mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-05-28 20:08:10 +00:00
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:
@@ -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."}});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user