mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-01 05:03:52 +00:00
Change positionals to deque, no reverse needed
This commit is contained in:
parent
30a91b4a72
commit
b5ea5ce065
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <deque>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@ -321,7 +322,7 @@ protected:
|
|||||||
std::string prog_discription;
|
std::string prog_discription;
|
||||||
std::vector<Option> options;
|
std::vector<Option> options;
|
||||||
std::vector<std::string> missing_options;
|
std::vector<std::string> missing_options;
|
||||||
std::vector<std::string> positionals;
|
std::deque<std::string> positionals;
|
||||||
std::vector<App*> subcommands;
|
std::vector<App*> subcommands;
|
||||||
bool parsed{false};
|
bool parsed{false};
|
||||||
App* subcommand = nullptr;
|
App* subcommand = nullptr;
|
||||||
@ -541,14 +542,12 @@ public:
|
|||||||
throw CallForHelp();
|
throw CallForHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Positionals end up being inserted in the correct order, but we want to pop them off the back end
|
|
||||||
std::reverse(std::begin(positionals), std::end(positionals));
|
|
||||||
|
|
||||||
for(Option& opt : options) {
|
for(Option& opt : options) {
|
||||||
while (opt.positional() && opt.count() < opt.expected() && positionals.size() > 0) {
|
while (opt.positional() && opt.count() < opt.expected() && positionals.size() > 0) {
|
||||||
opt.get_new();
|
opt.get_new();
|
||||||
opt.add_result(0, positionals.back());
|
opt.add_result(0, positionals.front());
|
||||||
positionals.pop_back();
|
positionals.pop_front();
|
||||||
}
|
}
|
||||||
if (opt.required() && opt.count() < opt.expected())
|
if (opt.required() && opt.count() < opt.expected())
|
||||||
throw RequiredError(opt.get_name());
|
throw RequiredError(opt.get_name());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user