From 66b6fff0f2eb3aea07048ff7749b4280f9cb6c54 Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 29 May 2023 18:09:34 +0200 Subject: [PATCH] Fix greediness of greedy arguments if they have sub arguments Even sub arguments (e.g. `--help`) should be treated as values to be passed to a nested argument parser (as documented). The sub arguments are only added in this case to appear in the help. --- application/argumentparser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/application/argumentparser.cpp b/application/argumentparser.cpp index 4493993..da21eef 100644 --- a/application/argumentparser.cpp +++ b/application/argumentparser.cpp @@ -361,6 +361,9 @@ bool ArgumentReader::read(ArgumentVector &args) ++parser.m_actualArgc; lastArg = lastArgInLevel = matchingArg; argDenotation = nullptr; + if ((values->size() < matchingArg->requiredValueCount()) && (matchingArg->flags() & Argument::Flags::Greedy)) { + continue; + } read(lastArg->m_subArgs); argDenotation = nullptr; continue;