Skip to content

Commit 1364746

Browse files
Fix the order of arguments in command-line parsing error message (#1158)
CLI11 code prints the command-line arguments in reversed order in the error message. Code to reproduce: ```c++ #include <string> #include <CLI/CLI.hpp> int main(int argc, const char **argv) { CLI::App app{"Bug report app"}; std::string foo; app.add_option("--foo", foo, "Foo option"); CLI11_PARSE(app, argc, argv); return 0; } ``` Reproduction: ``` $ g++ -Wall -Wextra -I CLI11/include/ cli11-bug-order-in-error.cpp -o cli11-bug-order-in-error && ./cli11-bug-order-in-error --foo bar --fizz buzz The following arguments were not expected: buzz --fizz Run with --help for more information. ``` Expected result: ``` The following arguments were not expected: --fizz buzz Run with --help for more information. ```
1 parent c31476b commit 1364746

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/CLI/Error.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ class ExtrasError : public ParseError {
310310
explicit ExtrasError(std::vector<std::string> args)
311311
: ExtrasError((args.size() > 1 ? "The following arguments were not expected: "
312312
: "The following argument was not expected: ") +
313-
detail::rjoin(args, " "),
313+
detail::join(args, " "),
314314
ExitCodes::ExtrasError) {}
315315
ExtrasError(const std::string &name, std::vector<std::string> args)
316316
: ExtrasError(name,
317317
(args.size() > 1 ? "The following arguments were not expected: "
318318
: "The following argument was not expected: ") +
319-
detail::rjoin(args, " "),
319+
detail::join(args, " "),
320320
ExitCodes::ExtrasError) {}
321321
};
322322

0 commit comments

Comments
 (0)