Skip to content

Commit 14d0df8

Browse files
authored
Merge pull request #186 from eseiler/misc/format_exit
[MISC] Move std::exit for special formats to parser
2 parents f0b5fc3 + 66fa140 commit 14d0df8

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

include/sharg/detail/format_base.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,6 @@ class format_help_base : public format_base
357357
print_legal();
358358

359359
derived_t().print_footer();
360-
361-
std::exit(EXIT_SUCCESS); // program should not continue from here
362360
}
363361

364362
/*!\brief Adds a print_section call to parser_set_up_calls.

include/sharg/detail/format_help.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ class format_short_help : public format_help
422422
print_synopsis();
423423

424424
print_line("Try -h or --help for more information.\n", true);
425-
426-
std::exit(EXIT_SUCCESS);
427425
}
428426
};
429427

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

451449
print_header();
452450
print_version();
453-
454-
std::exit(EXIT_SUCCESS); // program should not continue from here
455451
}
456452
};
457453

@@ -526,8 +522,6 @@ DAMAGE.)"};
526522
<< in_bold("This program contains SeqAn code licensed under the following terms:\n")
527523
<< std::string(80, '-') << '\n'
528524
<< seqan_license << '\n';
529-
530-
std::exit(EXIT_SUCCESS);
531525
}
532526
};
533527

include/sharg/parser.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ class parser
440440
},
441441
format);
442442
parse_was_called = true;
443+
444+
// Exit after parsing any special format.
445+
if (!std::holds_alternative<detail::format_parse>(format))
446+
std::exit(EXIT_SUCCESS);
443447
}
444448

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

0 commit comments

Comments
 (0)