Skip to content

[MISC] Move std::exit for special formats to parser #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/sharg/detail/format_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions include/sharg/detail/format_help.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand All @@ -450,8 +448,6 @@ class format_version : public format_help

print_header();
print_version();

std::exit(EXIT_SUCCESS); // program should not continue from here
}
};

Expand Down Expand Up @@ -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);
}
};

Expand Down
4 changes: 4 additions & 0 deletions include/sharg/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ class parser
},
format);
parse_was_called = true;

// Exit after parsing any special format.
if (!std::holds_alternative<detail::format_parse>(format))
std::exit(EXIT_SUCCESS);
}

/*!\brief Returns a reference to the sub-parser instance if
Expand Down