From 66fa140f5bb0cc8593433b0510f613f122b0671e Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Tue, 21 Feb 2023 20:34:10 +0100 Subject: [PATCH] [MISC] Move std::exit for special formats to parser --- include/sharg/detail/format_base.hpp | 2 -- include/sharg/detail/format_help.hpp | 6 ------ include/sharg/parser.hpp | 4 ++++ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/sharg/detail/format_base.hpp b/include/sharg/detail/format_base.hpp index 25a9223a..5f32a29e 100644 --- a/include/sharg/detail/format_base.hpp +++ b/include/sharg/detail/format_base.hpp @@ -357,8 +357,6 @@ class format_help_base : public format_base print_legal(); derived_t().print_footer(); - - std::exit(EXIT_SUCCESS); // program should not continue from here } /*!\brief Adds a print_section call to parser_set_up_calls. diff --git a/include/sharg/detail/format_help.hpp b/include/sharg/detail/format_help.hpp index 337e8033..1fc6be5b 100644 --- a/include/sharg/detail/format_help.hpp +++ b/include/sharg/detail/format_help.hpp @@ -422,8 +422,6 @@ class format_short_help : public format_help print_synopsis(); print_line("Try -h or --help for more information.\n", true); - - std::exit(EXIT_SUCCESS); } }; @@ -450,8 +448,6 @@ class format_version : public format_help print_header(); print_version(); - - std::exit(EXIT_SUCCESS); // program should not continue from here } }; @@ -526,8 +522,6 @@ DAMAGE.)"}; << in_bold("This program contains SeqAn code licensed under the following terms:\n") << std::string(80, '-') << '\n' << seqan_license << '\n'; - - std::exit(EXIT_SUCCESS); } }; diff --git a/include/sharg/parser.hpp b/include/sharg/parser.hpp index 8fedb766..935fccaa 100644 --- a/include/sharg/parser.hpp +++ b/include/sharg/parser.hpp @@ -440,6 +440,10 @@ class parser }, format); parse_was_called = true; + + // Exit after parsing any special format. + if (!std::holds_alternative(format)) + std::exit(EXIT_SUCCESS); } /*!\brief Returns a reference to the sub-parser instance if