add checks and fixes for extrasError argument order (#1162)

Adds tests and checks for Extras Error 
Builds on #1158

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top
2025-05-09 08:06:25 -07:00
committed by GitHub
parent 1364746d4c
commit 990956f4f8
3 changed files with 30 additions and 3 deletions

View File

@@ -1800,7 +1800,10 @@ CLI11_INLINE bool App::_parse_positional(std::vector<std::string> &args, bool ha
}
}
if(positionals_at_end_) {
throw CLI::ExtrasError(name_, args);
std::vector<std::string> rargs;
rargs.resize(args.size());
std::reverse_copy(args.begin(), args.end(), rargs.begin());
throw CLI::ExtrasError(name_, rargs);
}
/// If this is an option group don't deal with it
if(parent_ != nullptr && name_.empty()) {