From cecfe06ebc6c4ee46f15772cfba30b943ee34721 Mon Sep 17 00:00:00 2001 From: "Taylor C. Richberger" Date: Mon, 9 Jan 2023 09:18:47 -0700 Subject: [PATCH] Make sure options message appears before positionals --- args.hxx | 16 ++++++++++------ examples/gitlike.cxx | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/args.hxx b/args.hxx index d3967f8..25f4127 100644 --- a/args.hxx +++ b/args.hxx @@ -2014,7 +2014,16 @@ namespace args { UpdateSubparserHelp(params); - auto res = Group::GetProgramLine(params); + std::vector res; + + if ((subparserHasFlag || Group::HasFlag()) && params.showProglineOptions && !params.proglineShowFlags) + { + res.push_back(params.proglineOptions); + } + + auto group_res = Group::GetProgramLine(params); + std::move(std::move(group_res).begin(), std::move(group_res).end(), std::back_inserter(res)); + res.insert(res.end(), subparserProgramLine.begin(), subparserProgramLine.end()); if (!params.proglineCommand.empty() && (Group::HasCommand() || subparserHasCommand)) @@ -2027,11 +2036,6 @@ namespace args res.insert(res.begin(), Name()); } - if ((subparserHasFlag || Group::HasFlag()) && params.showProglineOptions && !params.proglineShowFlags) - { - res.push_back(params.proglineOptions); - } - if (!ProglinePostfix().empty()) { std::string line; diff --git a/examples/gitlike.cxx b/examples/gitlike.cxx index aa0e20e..cb130c8 100644 --- a/examples/gitlike.cxx +++ b/examples/gitlike.cxx @@ -5,7 +5,7 @@ #include #include #include -#include +#include "args.hxx" void Init(const std::string &progname, std::vector::const_iterator beginargs, std::vector::const_iterator endargs); void Add(const std::string &progname, std::vector::const_iterator beginargs, std::vector::const_iterator endargs);