WIP: Keep track of implicitly adding args
This commit is contained in:
parent
df7a3ee93c
commit
3501fe20b8
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue