3 #include "../conversion/stringbuilder.h" 5 #include "../application/argumentparser.h" 6 #include "../application/argumentparserprivate.h" 7 #include "../application/commandlineutils.h" 8 #include "../application/failure.h" 9 #include "../application/fakeqtconfigarguments.h" 11 #include "../io/path.h" 13 #include "resources/config.h" 15 #include <cppunit/TestFixture.h> 16 #include <cppunit/extensions/HelperMacros.h> 32 CPPUNIT_TEST(testArgument);
33 CPPUNIT_TEST(testParsing);
34 CPPUNIT_TEST(testCallbacks);
35 CPPUNIT_TEST(testBashCompletion);
36 CPPUNIT_TEST(testHelp);
37 CPPUNIT_TEST(testSetMainArguments);
38 CPPUNIT_TEST_SUITE_END();
47 void testBashCompletion();
49 void testSetMainArguments();
70 Argument argument(
"test",
't',
"some description");
71 CPPUNIT_ASSERT_EQUAL(argument.
isRequired(),
false);
73 CPPUNIT_ASSERT_EQUAL(argument.
isRequired(),
true);
74 Argument subArg(
"sub",
's',
"sub arg");
76 CPPUNIT_ASSERT_EQUAL(subArg.parents().at(0), &argument);
77 CPPUNIT_ASSERT(!subArg.conflictsWithArgument());
80 setenv(
"FOO_ENV_VAR",
"foo",
true);
81 CPPUNIT_ASSERT(!strcmp(argument.
firstValue(),
"foo"));
83 occurrence.
values.emplace_back(
"bar");
84 argument.m_occurrences.emplace_back(move(occurrence));
85 CPPUNIT_ASSERT(!strcmp(argument.
firstValue(),
"bar"));
98 Argument verboseArg(
"verbose",
'v',
"be verbose");
100 Argument fileArg(
"file",
'f',
"specifies the path of the file to be opened");
104 Argument filesArg(
"files",
'f',
"specifies the path of the file(s) to be opened");
107 Argument outputFileArg(
"output-file",
'o',
"specifies the path of the output file");
112 Argument printFieldNamesArg(
"print-field-names",
'\0',
"prints available field names");
113 Argument displayFileInfoArg(
"display-file-info",
'i',
"displays general file information");
114 Argument notAlbumArg(
"album",
'a',
"should not be confused with album value");
116 displayFileInfoArg.
setSubArguments({ &fileArg, &verboseArg, ¬AlbumArg });
117 Argument fieldsArg(
"fields",
'\0',
"specifies the fields");
119 fieldsArg.
setValueNames({
"title",
"album",
"artist",
"trackpos" });
121 Argument displayTagInfoArg(
"get",
'p',
"displays the values of all specified tag fields (displays all fields if none specified)");
123 displayTagInfoArg.
setSubArguments({ &fieldsArg, &filesArg, &verboseArg, ¬AlbumArg });
124 parser.
setMainArguments({ &qtConfigArgs.qtWidgetsGuiArg(), &printFieldNamesArg, &displayTagInfoArg, &displayFileInfoArg, &helpArg });
127 const char *argv[] = {
"tageditor",
"get",
"album",
"title",
"diskpos",
"-f",
"somefile" };
131 CPPUNIT_FAIL(
"Exception expected.");
133 CPPUNIT_ASSERT(!strcmp(e.
what(),
"The argument \"files\" can not be combined with \"fields\"."));
141 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
142 CPPUNIT_ASSERT(!displayFileInfoArg.
isPresent());
143 CPPUNIT_ASSERT(!strcmp(parser.
executable(),
"tageditor"));
145 CPPUNIT_ASSERT(displayTagInfoArg.
isPresent());
147 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(0),
"album"));
148 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(1),
"title"));
149 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(2),
"diskpos"));
150 CPPUNIT_ASSERT_THROW(displayTagInfoArg.
values().at(3), out_of_range);
153 const char *argv2[] = {
"tageditor",
"",
"-p",
"album",
"title",
"diskpos",
"",
"--files",
"somefile" };
158 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
159 CPPUNIT_ASSERT(!displayFileInfoArg.
isPresent());
161 CPPUNIT_ASSERT(displayTagInfoArg.
isPresent());
163 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(0),
"album"));
164 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(1),
"title"));
165 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(2),
"diskpos"));
166 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(3),
""));
167 CPPUNIT_ASSERT_THROW(fieldsArg.
values().at(4), out_of_range);
169 CPPUNIT_ASSERT(!strcmp(filesArg.
values().at(0),
"somefile"));
172 const char *argv3[] = {
"tageditor",
"album",
"title",
"diskpos",
"--files",
"somefile" };
176 CPPUNIT_FAIL(
"Exception expected.");
178 CPPUNIT_ASSERT_EQUAL(
"The specified argument \"album\" is unknown."s,
string(e.
what()));
185 streambuf *regularCerrBuffer = cerr.rdbuf(buffer.rdbuf());
190 cerr.rdbuf(regularCerrBuffer);
193 cerr.rdbuf(regularCerrBuffer);
194 CPPUNIT_ASSERT_EQUAL(
"The specified argument \"album\" is unknown and will be ignored.\n"s
195 "The specified argument \"title\" is unknown and will be ignored.\n"s
196 "The specified argument \"diskpos\" is unknown and will be ignored.\n"s
197 "The specified argument \"--files\" is unknown and will be ignored.\n"s
198 "The specified argument \"somefile\" is unknown and will be ignored.\n"s,
201 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
202 CPPUNIT_ASSERT(!displayFileInfoArg.
isPresent());
203 CPPUNIT_ASSERT(!displayTagInfoArg.
isPresent());
208 const char *argv4[] = {
"tageditor",
"-i",
"-vf",
"test" };
212 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
213 CPPUNIT_ASSERT(displayFileInfoArg.
isPresent());
215 CPPUNIT_ASSERT(!displayTagInfoArg.
isPresent());
218 CPPUNIT_ASSERT(!strcmp(fileArg.
values().at(0),
"test"));
219 CPPUNIT_ASSERT_THROW(fileArg.
values().at(1), out_of_range);
225 CPPUNIT_FAIL(
"Exception expected.");
227 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
228 CPPUNIT_ASSERT(!strcmp(e.
what(),
"The argument \"verbose\" mustn't be specified more than 1 time."));
235 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
241 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
244 const char *argv5[] = {
"tageditor",
"-i",
"-f",
"test" };
248 CPPUNIT_FAIL(
"Exception expected.");
250 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
251 CPPUNIT_ASSERT(!strcmp(e.
what(),
"The argument \"verbose\" must be specified at least 1 time."));
256 const char *argv10[] = {
"tageditor",
"-pf",
"test" };
259 CPPUNIT_ASSERT(displayTagInfoArg.
isPresent());
260 CPPUNIT_ASSERT(!displayFileInfoArg.
isPresent());
263 CPPUNIT_ASSERT_EQUAL(filesArg.
values(0).size(),
static_cast<vector<const char *>::size_type
>(1));
264 CPPUNIT_ASSERT(!strcmp(filesArg.
values(0).front(),
"test"));
265 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
268 const char *argv6[] = {
"tageditor",
"-g" };
271 CPPUNIT_ASSERT(qtConfigArgs.qtWidgetsGuiArg().isPresent());
274 const char *argv7[] = {
"tageditor",
"-f",
"test" };
278 CPPUNIT_FAIL(
"Exception expected.");
280 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
281 CPPUNIT_ASSERT_EQUAL(
"The specified argument \"-f\" is unknown."s,
string(e.
what()));
285 const char *argv11[] = {
"tageditor",
"-if=test" };
290 CPPUNIT_ASSERT_EQUAL(fileArg.
values(0).size(),
static_cast<vector<const char *>::size_type
>(1));
291 CPPUNIT_ASSERT(!strcmp(fileArg.
values(0).front(),
"test"));
294 const char *argv12[] = {
"tageditor",
"-iftest" };
299 CPPUNIT_ASSERT_EQUAL(fileArg.
values(0).size(),
static_cast<vector<const char *>::size_type
>(1));
300 CPPUNIT_ASSERT(!strcmp(fileArg.
values(0).front(),
"test"));
303 const char *argv8[] = {
"tageditor" };
306 CPPUNIT_ASSERT(qtConfigArgs.qtWidgetsGuiArg().isPresent());
307 CPPUNIT_ASSERT(!displayFileInfoArg.
isPresent());
309 CPPUNIT_ASSERT(!displayTagInfoArg.
isPresent());
312 if (getenv(
"PATH")) {
314 CPPUNIT_ASSERT(!strcmp(fileArg.
firstValue(), getenv(
"PATH")));
320 const char *argv13[] = {
"tageditor",
"get",
"--fields",
"album=test",
"title",
"diskpos",
"--files",
"somefile" };
325 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
326 CPPUNIT_ASSERT(!displayFileInfoArg.
isPresent());
328 CPPUNIT_ASSERT(displayTagInfoArg.
isPresent());
330 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(0),
"album=test"));
331 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(1),
"title"));
332 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(2),
"diskpos"));
333 CPPUNIT_ASSERT_THROW(fieldsArg.
values().at(3), out_of_range);
335 CPPUNIT_ASSERT(!strcmp(filesArg.
values().at(0),
"somefile"));
336 CPPUNIT_ASSERT(!notAlbumArg.
isPresent());
339 const char *argv9[] = {
"tageditor",
"-p",
"album",
"title",
"diskpos" };
344 CPPUNIT_FAIL(
"Exception expected.");
346 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
347 CPPUNIT_ASSERT(!strcmp(e.
what(),
348 "Not all parameter for argument \"fields\" provided. You have to provide the following parameter: title album artist trackpos"));
352 const char *argv14[] = {
"tageditor",
"get",
"fields",
"album=test",
"-f",
"somefile" };
357 CPPUNIT_ASSERT(displayTagInfoArg.
isPresent());
359 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(0),
"album=test"));
365 CPPUNIT_ASSERT(displayTagInfoArg.
isPresent());
367 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(0),
"fields"));
368 CPPUNIT_ASSERT(!strcmp(fieldsArg.
values().at(1),
"album=test"));
377 Argument callbackArg(
"with-callback",
't',
"callback test");
380 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), occurrence.
index);
381 CPPUNIT_ASSERT(occurrence.
path.empty());
382 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), occurrence.
values.size());
383 CPPUNIT_ASSERT(!strcmp(occurrence.
values[0],
"val1"));
384 CPPUNIT_ASSERT(!strcmp(occurrence.
values[1],
"val2"));
387 Argument noCallbackArg(
"no-callback",
'l',
"callback test");
392 const char *argv[] = {
"test",
"-t",
"val1",
"val2" };
396 CPPUNIT_ASSERT_EQUAL(i, 42);
401 const char *argv2[] = {
"test",
"-l",
"val1",
"val2" };
414 Argument verboseArg(
"verbose",
'v',
"be verbose");
416 Argument filesArg(
"files",
'f',
"specifies the path of the file(s) to be opened");
419 Argument nestedSubArg(
"nested-sub",
'\0',
"nested sub arg");
420 Argument subArg(
"sub",
'\0',
"sub arg");
422 Argument displayFileInfoArg(
"display-file-info",
'i',
"displays general file information");
424 displayFileInfoArg.
setSubArguments({ &filesArg, &verboseArg, &subArg });
425 Argument fieldsArg(
"fields",
'\0',
"specifies the fields");
429 Argument valuesArg(
"values",
'\0',
"specifies the fields");
433 valuesArg.
setValueCompletionBehavior(ValueCompletionBehavior::PreDefinedValues | ValueCompletionBehavior::AppendEquationSign);
434 Argument getArg(
"get",
'g',
"gets tag values");
436 Argument setArg(
"set",
's',
"sets tag values");
439 parser.
setMainArguments({ &helpArg, &displayFileInfoArg, &getArg, &setArg });
443 streambuf *regularCoutBuffer = cout.rdbuf(buffer.rdbuf());
447 const char *
const argv1[] = {
"se" };
450 parser.printBashCompletion(1, argv1, 0, reader);
451 cout.rdbuf(regularCoutBuffer);
452 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=()\n"s, buffer.str());
455 buffer.str(
string());
456 cout.rdbuf(buffer.rdbuf());
459 parser.printBashCompletion(1, argv1, 0, reader);
460 cout.rdbuf(regularCoutBuffer);
461 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('set' )\n"s, buffer.str());
464 const char *
const argv2[] = {
"set" };
465 buffer.str(
string());
466 cout.rdbuf(buffer.rdbuf());
469 parser.printBashCompletion(1, argv2, 0, reader);
470 cout.rdbuf(regularCoutBuffer);
471 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('set' )\n"s, buffer.str());
474 buffer.str(
string());
475 cout.rdbuf(buffer.rdbuf());
478 parser.printBashCompletion(1, argv2, 1, reader);
479 cout.rdbuf(regularCoutBuffer);
480 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('--files' '--values' )\n"s, buffer.str());
483 buffer.str(
string());
484 cout.rdbuf(buffer.rdbuf());
488 parser.printBashCompletion(1, argv2, 1, reader);
489 cout.rdbuf(regularCoutBuffer);
490 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('files' '--values' )\n"s, buffer.str());
493 buffer.str(
string());
494 cout.rdbuf(buffer.rdbuf());
498 parser.printBashCompletion(0,
nullptr, 0, reader);
499 cout.rdbuf(regularCoutBuffer);
500 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('display-file-info' 'get' 'set' '--help' )\n"s, buffer.str());
503 const char *
const argv3[] = {
"get",
"--fields" };
504 buffer.str(
string());
505 cout.rdbuf(buffer.rdbuf());
508 parser.printBashCompletion(2, argv3, 2, reader);
509 cout.rdbuf(regularCoutBuffer);
510 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('title' 'album' 'artist' 'trackpos' '--files' )\n"s, buffer.str());
513 const char *
const argv4[] = {
"set",
"--values",
"a" };
514 buffer.str(
string());
515 cout.rdbuf(buffer.rdbuf());
518 parser.printBashCompletion(3, argv4, 2, reader);
519 cout.rdbuf(regularCoutBuffer);
520 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('album=' 'artist=' ); compopt -o nospace\n"s, buffer.str());
524 iniFilePath.resize(iniFilePath.size() - 4);
526 mkvFilePath.resize(mkvFilePath.size() - 17);
528 const char *
const argv5[] = {
"get",
"--files", iniFilePath.c_str() };
529 buffer.str(
string());
530 cout.rdbuf(buffer.rdbuf());
533 parser.printBashCompletion(3, argv5, 2, reader);
534 cout.rdbuf(regularCoutBuffer);
536 const string res(buffer.str());
537 if (res.find(
".mkv") < res.find(
".ini")) {
538 CPPUNIT_ASSERT_EQUAL(
539 "COMPREPLY=('" % mkvFilePath %
" '\"'\"'with quote'\"'\"'.mkv' '" % iniFilePath +
".ini' ); compopt -o filenames\n", buffer.str());
541 CPPUNIT_ASSERT_EQUAL(
542 "COMPREPLY=('" % iniFilePath %
".ini' '" % mkvFilePath +
" '\"'\"'with quote'\"'\"'.mkv' ); compopt -o filenames\n", buffer.str());
546 const char *
const argv6[] = {
"set",
"--" };
547 buffer.str(
string());
548 cout.rdbuf(buffer.rdbuf());
551 parser.printBashCompletion(2, argv6, 1, reader);
552 cout.rdbuf(regularCoutBuffer);
553 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('--files' '--values' )\n"s, buffer.str());
556 const char *
const argv7[] = {
"-i",
"--sub",
"--" };
557 buffer.str(
string());
558 cout.rdbuf(buffer.rdbuf());
561 parser.printBashCompletion(3, argv7, 2, reader);
562 cout.rdbuf(regularCoutBuffer);
563 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('--files' '--nested-sub' '--verbose' )\n"s, buffer.str());
566 const char *
const argv8[] = {
"set",
"--values",
"t" };
567 buffer.str(
string());
568 cout.rdbuf(buffer.rdbuf());
571 parser.printBashCompletion(3, argv8, 2, reader);
572 cout.rdbuf(regularCoutBuffer);
573 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('title=' 'trackpos=' ); compopt -o nospace\n"s, buffer.str());
576 const char *
const argv9[] = {
"-gf" };
577 buffer.str(
string());
578 cout.rdbuf(buffer.rdbuf());
581 parser.printBashCompletion(1, argv9, 0, reader);
582 cout.rdbuf(regularCoutBuffer);
583 CPPUNIT_ASSERT_EQUAL(
"COMPREPLY=('-gf' )\n"s, buffer.str());
585 buffer.str(
string());
586 cout.rdbuf(buffer.rdbuf());
589 parser.printBashCompletion(1, argv9, 1, reader);
590 cout.rdbuf(regularCoutBuffer);
591 CPPUNIT_ASSERT_EQUAL(static_cast<string::size_type>(0), buffer.str().find(
"COMPREPLY=('--fields' "));
594 cout.rdbuf(regularCoutBuffer);
607 CPPUNIT_ASSERT_EQUAL(static_cast<unsigned char>(4 + 3), indent.
level);
611 streambuf *regularCoutBuffer = cout.rdbuf(buffer.rdbuf());
617 OperationArgument verboseArg(
"verbose",
'v',
"be verbose",
"actually not an operation");
619 ConfigValueArgument nestedSubArg(
"nested-sub",
'\0',
"nested sub arg", {
"value1",
"value2" });
621 Argument subArg(
"sub",
'\0',
"sub arg");
624 Argument filesArg(
"files",
'f',
"specifies the path of the file(s) to be opened");
628 Argument envArg(
"env",
'\0',
"env");
638 const char *
const argv[] = {
"app",
"-h" };
639 buffer.str(
string());
640 cout.rdbuf(buffer.rdbuf());
642 cout.rdbuf(regularCoutBuffer);
643 CPPUNIT_ASSERT_EQUAL(
"\e[1m" APP_NAME
", version " APP_VERSION
"\n" 645 "Available arguments:\n" 646 "\e[1m--help, -h\e[0m\n" 647 " shows this information\n" 648 " particularities: mandatory\n" 650 "\e[1m--verbose, -v\e[0m\n" 653 "usage: actually not an operation\n" 655 "\e[1m--files, -f\e[0m\n" 656 " specifies the path of the file(s) to be opened\n" 659 " particularities: mandatory if parent argument is present\n" 660 " \e[1m--nested-sub\e[0m [value1] [value2] ...\n" 663 "\e[1m--env\e[0m [file] [value 2]\n" 665 " default environment variable: FILES\n" 667 "Project website: " APP_URL
"\n"s,
678 Argument subArg(
"sub-arg",
's',
"mandatory sub arg");
683 CPPUNIT_ASSERT_MESSAGE(
"clear main args", parser.
mainArguments().empty());
685 CPPUNIT_ASSERT_MESSAGE(
"no default due to required sub arg", !parser.
defaultArgument());
688 CPPUNIT_ASSERT_MESSAGE(
"default if no required sub arg", &helpArg == parser.
defaultArgument());
void testBashCompletion()
Tests bash completion.
void resetArgs()
Resets all Argument instances assigned as mainArguments() and sub arguments.
#define QT_CONFIG_ARGUMENTS
The ConfigValueArgument class is an Argument where setCombinable() is true by default.
Argument * defaultArgument() const
Returns the default argument.
void setImplicit(bool value)
Sets whether the argument is an implicit argument.
std::size_t index
The index of the occurrence.
void testParsing()
Tests parsing command line arguments.
void setCombinable(bool value)
Sets whether this argument can be combined.
void setUnknownArgumentBehavior(UnknownArgumentBehavior behavior)
Sets how unknown arguments are treated.
virtual const char * what() const USE_NOTHROW
Returns a C-style character string describing the cause of the Failure.
Contains currently only ArgumentParser and related classes.
void setMainArguments(const ArgumentInitializerList &mainArguments)
Sets the main arguments for the parser.
void testArgument()
Tests the behaviour of the argument class.
void testSetMainArguments()
Tests some corner cases in setMainArguments() which are not already checked in the other tests...
bool isRequired() const
Returns an indication whether the argument is mandatory.
void testCallbacks()
Tests whether callbacks are called correctly.
void setRequired(bool required)
Sets whether this argument is mandatory or not.
void parseArgs(int argc, const char *const *argv)
Parses the specified command line arguments.
const char * firstValue() const
Returns the first parameter value of the first occurrence of the argument.
The Indentation class allows printing indentation conveniently, eg.
void addMainArgument(Argument *argument)
Adds the specified argument to the main argument.
The ArgumentParserTests class tests the ArgumentParser and Argument classes.
The OperationArgument class is an Argument where denotesOperation() is true by default.
void setConstraints(std::size_t minOccurrences, std::size_t maxOccurrences)
Sets the allowed number of occurrences.
void setValueCompletionBehavior(ValueCompletionBehavior valueCompletionBehaviour)
Sets the items to be considered when generating completion for the values.
#define SET_APPLICATION_INFO
SET_APPLICATION_INFO
void appendValueName(const char *valueName)
Appends a value name.
const std::vector< const char * > & values(std::size_t occurrence=0) const
Returns the parameter values for the specified occurrence of argument.
Contains several functions providing conversions between different data types.
const char * executable() const
Returns the name of the current executable.
The Argument class is a wrapper for command line argument information.
void setCallback(CallbackFunction callback)
Sets a callback function which will be called by the parser if the argument could be found and no par...
void setPreDefinedCompletionValues(const char *preDefinedCompletionValues)
Assignes the values to be used when generating completion for the values.
ApplicationUtilities::ArgumentReader & reset(const char *const *argv, const char *const *end)
Resets the ArgumentReader to continue reading new argv.
std::vector< Argument * > path
The "path" of the occurrence (the parent elements which have been specified before).
void addSubArgument(Argument *arg)
Adds arg as a secondary argument for this argument.
void setEnvironmentVariable(const char *environmentVariable)
Sets the environment variable queried when firstValue() is called.
The ArgumentOccurrence struct holds argument values for an occurrence of an argument.
bool isPresent() const
Returns an indication whether the argument could be detected when parsing.
The HelpArgument class prints help information for an argument parser when present (–help...
CPPUNIT_TEST_SUITE_REGISTRATION(ArgumentParserTests)
The Failure class is thrown by an ArgumentParser when a parsing error occurs.
const ArgumentVector & mainArguments() const
Returns the main arguments.
void setDenotesOperation(bool denotesOperation)
Sets whether the argument denotes the operation.
void reset()
Resets occurrences (indices, values and paths).
void setRequiredValueCount(std::size_t requiredValueCount)
Sets the number of values which are required to be given for this argument.
void setSubArguments(const ArgumentInitializerList &subArguments)
Sets the secondary arguments for this arguments.
void read()
Reads the commands line arguments specified when constructing the object.
CPP_UTILITIES_EXPORT std::string testFilePath(const std::string &name)
Convenience function which returns the full path of the test file with the specified name...
The ArgumentParser class provides a means for handling command line arguments.
void testHelp()
Tests –help output.
void setValueNames(std::initializer_list< const char *> valueNames)
Sets the names of the requried values.
std::vector< const char * > values
The parameter values which have been specified after the occurrence of the argument.