diff --git a/application/argumentparser.cpp b/application/argumentparser.cpp index 360f440..62a1514 100644 --- a/application/argumentparser.cpp +++ b/application/argumentparser.cpp @@ -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; } } diff --git a/application/argumentparser.h b/application/argumentparser.h index 3fca91c..c5a1b86 100644 --- a/application/argumentparser.h +++ b/application/argumentparser.h @@ -245,6 +245,13 @@ public: */ static constexpr std::size_t varValueCount = std::numeric_limits::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::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 {