Skip to content

Commit

Permalink
Make sure options message appears before positionals
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor C. Richberger committed Jan 9, 2023
1 parent 3e70c39 commit cecfe06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions args.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,16 @@ namespace args
{
UpdateSubparserHelp(params);

auto res = Group::GetProgramLine(params);
std::vector<std::string> 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))
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/gitlike.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <iostream>
#include <unordered_map>
#include <functional>
#include <args.hxx>
#include "args.hxx"

void Init(const std::string &progname, std::vector<std::string>::const_iterator beginargs, std::vector<std::string>::const_iterator endargs);
void Add(const std::string &progname, std::vector<std::string>::const_iterator beginargs, std::vector<std::string>::const_iterator endargs);
Expand Down

0 comments on commit cecfe06

Please sign in to comment.