WIP: Keep track of implicitly adding args

This commit is contained in:
Martchus 2018-03-24 17:01:31 +01:00
parent df7a3ee93c
commit 3501fe20b8
2 changed files with 10 additions and 2 deletions

View File

@ -240,13 +240,13 @@ void ArgumentReader::read(ArgumentVector &args)
}
}
// use the first default argument which is not already present if there is still no match
// use the first implicit argument which is not already present if there is still no match
if (!matchingArg && (!completionMode || (argv + 1 != end))) {
const bool uncombinableMainArgPresent = parentArg ? false : parser.isUncombinableMainArgPresent();
for (Argument *arg : args) {
if (arg->isImplicit() && !arg->isPresent() && !arg->wouldConflictWithArgument()
&& (!uncombinableMainArgPresent || !arg->isMainArgument())) {
(matchingArg = arg)->m_occurrences.emplace_back(index, parentPath, parentArg);
(matchingArg = arg)->m_occurrences.emplace_back(Argument::implicitOccurrence, parentPath, parentArg);
break;
}
}

View File

@ -245,6 +245,13 @@ public:
*/
static constexpr std::size_t varValueCount = std::numeric_limits<std::size_t>::max();
/*!
* \brief Indicates an implicit occurrence of an argument.
* \return This value is returned by Argument::index() if the argument has been implicitely added.
* \sa isImplicit(), setImplicit()
*/
static constexpr std::size_t implicitOccurrence = std::numeric_limits<std::size_t>::max();
private:
bool matchesDenotation(const char *denotation, size_t denotationLength) const;
@ -556,6 +563,7 @@ inline std::size_t Argument::occurrences() const
/*!
* \brief Returns the indices of the argument's occurences which could be detected when parsing.
* \remarks Might return Argument::implicitOccurrence in case the argument has been implicitely added.
*/
inline std::size_t Argument::index(std::size_t occurrence) const
{