mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Move ArgumentParser::parse_args_validate logic into ::parse_args
This code was previously moved from ::parse_args to its own method, but
has since been simplified. Moving the actual work to Argument::validate
in commit 603e87ae6
leaves a single loop that fits back into ::parse_args.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This commit is contained in:
parent
063d708c3e
commit
843e4eefb0
@ -958,7 +958,10 @@ public:
|
||||
*/
|
||||
void parse_args(const std::vector<std::string> &arguments) {
|
||||
parse_args_internal(arguments);
|
||||
parse_args_validate();
|
||||
// Check if all arguments are parsed
|
||||
for (const auto& [unused, argument] : m_argument_map) {
|
||||
argument->validate();
|
||||
}
|
||||
}
|
||||
|
||||
/* Main entry point for parsing command-line arguments using this
|
||||
@ -1134,16 +1137,6 @@ private:
|
||||
m_is_parsed = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @throws std::runtime_error in case of any invalid argument
|
||||
*/
|
||||
void parse_args_validate() {
|
||||
// Check if all arguments are parsed
|
||||
for (const auto& [unused, argument] : m_argument_map) {
|
||||
argument->validate();
|
||||
}
|
||||
}
|
||||
|
||||
// Used by print_help.
|
||||
std::size_t get_length_of_longest_argument() const {
|
||||
if (m_argument_map.empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user