Browse Source

Add Argument::varValueCount

testing/bash_completion_debugging
Martchus 5 years ago
parent
commit
3bc1756425
  1. 10
      application/argumentparser.h
  2. 3
      tests/testutils.cpp

10
application/argumentparser.h

@ -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()

3
tests/testutils.cpp

@ -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…
Cancel
Save