Add Argument::varValueCount
This commit is contained in:
parent
2e98e3bd11
commit
3bc1756425
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
#ifdef DEBUG_BUILD
|
||||
#include <cassert>
|
||||
|
@ -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<std::size_t>::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()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <fstream>
|
||||
#include <initializer_list>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
#include <poll.h>
|
||||
|
@ -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 });
|
||||
|
|
Loading…
Reference in New Issue