diff --git a/application/argumentparser.h b/application/argumentparser.h index 6a2f349..b9bb736 100644 --- a/application/argumentparser.h +++ b/application/argumentparser.h @@ -5,6 +5,7 @@ #include #include +#include #include #ifdef DEBUG_BUILD #include @@ -200,6 +201,12 @@ public: void reset(); void resetRecursively(); + /*! + * \brief Denotes a variable number of values. + * \sa setRequiredValueCount() + */ + static constexpr std::size_t varValueCount = std::numeric_limits::max(); + private: const char *m_name; char m_abbreviation; @@ -405,7 +412,8 @@ inline std::size_t Argument::requiredValueCount() const * for this argument. * * The parser will expect that many values when parsing command line arguments. - * A negative value indicates a variable number of arguments to be expected. + * Pass Argument::varValueCount for a variable number of arguments + * to be expected. * * \sa requiredValueCount() * \sa valueNames() diff --git a/tests/testutils.cpp b/tests/testutils.cpp index 52c3a0c..103d180 100644 --- a/tests/testutils.cpp +++ b/tests/testutils.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef PLATFORM_UNIX #include @@ -67,7 +68,7 @@ TestApplication::TestApplication(int argc, char **argv) arg->setValueNames({ "path" }); arg->setCombinable(true); } - m_unitsArg.setRequiredValueCount(-1); + m_unitsArg.setRequiredValueCount(Argument::varValueCount); m_unitsArg.setValueNames({ "unit1", "unit2", "unit3" }); m_unitsArg.setCombinable(true); m_parser.setMainArguments({ &m_testFilesPathArg, &m_applicationPathArg, &m_workingDirArg, &m_unitsArg, &m_helpArg });