124 parser.setExitFunction(std::bind(&ArgumentParserTests::failOnExit,
this, std::placeholders::_1));
127 auto verboseArg =
Argument(
"verbose",
'v',
"be verbose");
128 verboseArg.setCombinable(
true);
129 auto fileArg =
Argument(
"file",
'f',
"specifies the path of the file to be opened");
130 fileArg.setValueNames({
"path" });
131 fileArg.setRequiredValueCount(1);
132 fileArg.setEnvironmentVariable(
"PATH");
133 auto filesArg =
Argument(
"files",
'f',
"specifies the path of the file(s) to be opened");
134 filesArg.setValueNames({
"path 1",
"path 2" });
136 auto outputFileArg =
Argument(
"output-file",
'o',
"specifies the path of the output file");
137 outputFileArg.setValueNames({
"path" });
138 outputFileArg.setRequiredValueCount(1);
139 outputFileArg.setRequired(
true);
140 outputFileArg.setCombinable(
true);
141 auto printFieldNamesArg =
Argument(
"print-field-names",
'\0',
"prints available field names");
142 auto displayFileInfoArg =
Argument(
"display-file-info",
'i',
"displays general file information");
143 auto notAlbumArg =
Argument(
"album",
'a',
"should not be confused with album value");
144 displayFileInfoArg.setDenotesOperation(
true);
145 displayFileInfoArg.setSubArguments({ &fileArg, &verboseArg, ¬AlbumArg });
146 auto fieldsArg =
Argument(
"fields",
'\0',
"specifies the fields");
148 fieldsArg.setValueNames({
"title",
"album",
"artist",
"trackpos" });
149 fieldsArg.setImplicit(
true);
150 auto displayTagInfoArg =
Argument(
"get",
'p',
"displays the values of all specified tag fields (displays all fields if none specified)");
151 displayTagInfoArg.setDenotesOperation(
true);
152 displayTagInfoArg.setSubArguments({ &fieldsArg, &filesArg, &verboseArg, ¬AlbumArg });
153 parser.setMainArguments(
154 { &qtConfigArgs.qtWidgetsGuiArg(), &printFieldNamesArg, &displayTagInfoArg, &displayFileInfoArg, &parser.noColorArg(), &parser.helpArg() });
157 parser.parseArgs(0,
nullptr, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
158 CPPUNIT_ASSERT(!parser.executable());
159 CPPUNIT_ASSERT(!parser.specifiedOperation());
160 CPPUNIT_ASSERT_EQUAL(0u, parser.actualArgumentCount());
163 const char *argv[] = {
"tageditor",
"get",
"album",
"title",
"diskpos",
"-f",
"somefile" };
166 parser.parseArgs(7, argv, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
167 CPPUNIT_FAIL(
"Exception expected.");
169 CPPUNIT_ASSERT_EQUAL(
"The argument \"files\" can not be combined with \"fields\"."s,
string(e.what()));
171 auto ss = std::stringstream();
173 CPPUNIT_ASSERT_EQUAL(
174 "Error: Unable to parse arguments: The argument \"files\" can not be combined with \"fields\".\nSee --help for available commands.\n"sv,
175 std::string_view(ss.str()));
177 CPPUNIT_ASSERT(parser.isUncombinableMainArgPresent());
180 filesArg.setCombinable(
true);
182 parser.parseArgs(7, argv, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
184 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
185 CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
186 CPPUNIT_ASSERT_EQUAL(
"tageditor"sv, std::string_view(parser.executable()));
187 CPPUNIT_ASSERT(!verboseArg.isPresent());
188 CPPUNIT_ASSERT(displayTagInfoArg.isPresent());
189 CPPUNIT_ASSERT(fieldsArg.isPresent());
190 CPPUNIT_ASSERT_EQUAL(
"album"sv, std::string_view(fieldsArg.values().at(0)));
191 CPPUNIT_ASSERT_EQUAL(
"title"sv, std::string_view(fieldsArg.values().at(1)));
192 CPPUNIT_ASSERT_EQUAL(
"diskpos"sv, std::string_view(fieldsArg.values().at(2)));
193 CPPUNIT_ASSERT_EQUAL(3_st, fieldsArg.values().size());
194 CPPUNIT_ASSERT_EQUAL(&displayTagInfoArg, parser.specifiedOperation());
197 const char *argv2[] = {
"tageditor",
"",
"-p",
"album",
"title",
"diskpos",
"",
"--files",
"somefile" };
200 parser.parseArgs(9, argv2, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
202 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
203 CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
204 CPPUNIT_ASSERT(!verboseArg.isPresent());
205 CPPUNIT_ASSERT(displayTagInfoArg.isPresent());
206 CPPUNIT_ASSERT(fieldsArg.isPresent());
207 CPPUNIT_ASSERT_EQUAL(
"album"sv, std::string_view(fieldsArg.values().at(0)));
208 CPPUNIT_ASSERT_EQUAL(
"title"sv, std::string_view(fieldsArg.values().at(1)));
209 CPPUNIT_ASSERT_EQUAL(
"diskpos"sv, std::string_view(fieldsArg.values().at(2)));
210 CPPUNIT_ASSERT_EQUAL(
""sv, std::string_view(fieldsArg.values().at(3)));
211 CPPUNIT_ASSERT_EQUAL(4_st, fieldsArg.values().size());
212 CPPUNIT_ASSERT(filesArg.isPresent());
213 CPPUNIT_ASSERT_EQUAL(
"somefile"sv, std::string_view(filesArg.values().at(0)));
216 const char *argv3[] = {
"tageditor",
"album",
"title",
"diskpos",
"--files",
"somefile" };
219 parser.parseArgs(6, argv3, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
220 CPPUNIT_FAIL(
"Exception expected.");
222 CPPUNIT_ASSERT_EQUAL(
"The specified argument \"album\" is unknown.\nDid you mean get or --help?"sv, std::string_view(e.what()));
226 const char *argv18[] = {
"tageditor",
"get",
"album",
"title",
"diskpos",
"--verbose",
"--fi" };
229 parser.parseArgs(7, argv18, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
230 CPPUNIT_FAIL(
"Exception expected.");
232 CPPUNIT_ASSERT_EQUAL(
"The specified argument \"--fi\" is unknown.\nDid you mean --files or --no-color?"sv, std::string_view(e.what()));
236 parser.setUnknownArgumentBehavior(UnknownArgumentBehavior::Warn);
238#ifndef PLATFORM_WINDOWS
239 const OutputCheck outputCheck(
"Warning: The specified argument \"album\" is unknown and will be ignored.\n"s
240 "Warning: The specified argument \"title\" is unknown and will be ignored.\n"s
241 "Warning: The specified argument \"diskpos\" is unknown and will be ignored.\n"s
242 "Warning: The specified argument \"--files\" is unknown and will be ignored.\n"s
243 "Warning: The specified argument \"somefile\" is unknown and will be ignored.\n"s,
248 parser.parseArgs(6, argv3, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
251 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
252 CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
253 CPPUNIT_ASSERT(!displayTagInfoArg.isPresent());
254 CPPUNIT_ASSERT(!fieldsArg.isPresent());
255 CPPUNIT_ASSERT(!filesArg.isPresent());
259 const char *argv4[] = {
"tageditor",
"-i",
"-vf",
"test" };
260 parser.setUnknownArgumentBehavior(UnknownArgumentBehavior::Fail);
262 parser.parseArgs(4, argv4, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
263 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
264 CPPUNIT_ASSERT(displayFileInfoArg.isPresent());
265 CPPUNIT_ASSERT(verboseArg.isPresent());
266 CPPUNIT_ASSERT(!displayTagInfoArg.isPresent());
267 CPPUNIT_ASSERT(!filesArg.isPresent());
268 CPPUNIT_ASSERT(fileArg.isPresent());
269 CPPUNIT_ASSERT_EQUAL(
"test"sv, std::string_view(fileArg.values().at(0)));
270 CPPUNIT_ASSERT_EQUAL(1_st, fileArg.values().size());
273 displayFileInfoArg.reset();
276 parser.parseArgs(4, argv4, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
277 CPPUNIT_FAIL(
"Exception expected.");
279 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
280 CPPUNIT_ASSERT_EQUAL(
"The argument \"verbose\" mustn't be specified more than 1 time."sv, std::string_view(e.what()));
284 displayFileInfoArg.reset();
287 parser.parseArgs(4, argv4, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
288 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
291 verboseArg.setRequired(
true);
293 parser.parseArgs(4, argv4, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
294 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
297 const char *argv5[] = {
"tageditor",
"-i",
"-f",
"test" };
298 displayFileInfoArg.reset();
302 parser.parseArgs(4, argv5, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
303 CPPUNIT_FAIL(
"Exception expected.");
305 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
306 CPPUNIT_ASSERT_EQUAL(
"The argument \"verbose\" must be specified at least 1 time."sv, std::string_view(e.what()));
308 verboseArg.setRequired(
false);
311 const char *argv10[] = {
"tageditor",
"-pf",
"test" };
313 parser.parseArgs(3, argv10, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
314 CPPUNIT_ASSERT(displayTagInfoArg.isPresent());
315 CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
316 CPPUNIT_ASSERT(!fileArg.isPresent());
317 CPPUNIT_ASSERT(filesArg.isPresent());
318 CPPUNIT_ASSERT_EQUAL(1_st, filesArg.values(0).size());
319 CPPUNIT_ASSERT_EQUAL(
"test"sv, std::string_view(filesArg.values(0).at(0)));
320 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
323 const char *argv6[] = {
"tageditor",
"-g" };
325 parser.parseArgs(2, argv6, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
326 CPPUNIT_ASSERT(qtConfigArgs.qtWidgetsGuiArg().isPresent());
329 const char *argv7[] = {
"tageditor",
"-f",
"test" };
332 parser.parseArgs(3, argv7, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
333 CPPUNIT_FAIL(
"Exception expected.");
335 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
336 CPPUNIT_ASSERT_EQUAL(
"The specified argument \"-f\" is unknown.\nDid you mean get or --help?"sv, std::string_view(e.what()));
340 const char *argv11[] = {
"tageditor",
"-if=test-v" };
342 parser.parseArgs(2, argv11, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
343 CPPUNIT_ASSERT(!filesArg.isPresent());
344 CPPUNIT_ASSERT(fileArg.isPresent());
345 CPPUNIT_ASSERT(!verboseArg.isPresent());
346 CPPUNIT_ASSERT_EQUAL(1_st, fileArg.values(0).size());
347 CPPUNIT_ASSERT_EQUAL(
"test-v"s,
string(fileArg.values(0).front()));
348 const char *argv15[] = {
"tageditor",
"-i",
"--file=test",
"-v" };
350 parser.parseArgs(4, argv15, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
351 CPPUNIT_ASSERT(!filesArg.isPresent());
352 CPPUNIT_ASSERT(fileArg.isPresent());
353 CPPUNIT_ASSERT(verboseArg.isPresent());
354 CPPUNIT_ASSERT_EQUAL(1_st, fileArg.values(0).size());
355 CPPUNIT_ASSERT_EQUAL(
"test"sv, std::string_view(fileArg.values(0).front()));
358 const char *argv12[] = {
"tageditor",
"-iftest" };
360 parser.parseArgs(2, argv12, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
361 CPPUNIT_ASSERT(!filesArg.isPresent());
362 CPPUNIT_ASSERT(fileArg.isPresent());
363 CPPUNIT_ASSERT_EQUAL(1_st, fileArg.values(0).size());
364 CPPUNIT_ASSERT_EQUAL(
"test"sv, std::string_view(fileArg.values().at(0)));
367 const char *argv17[] = {
"tageditor",
"-if=test-v",
"--no-color" };
369 parser.parseArgs(3, argv17, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
370 CPPUNIT_ASSERT(!filesArg.isPresent());
371 CPPUNIT_ASSERT(fileArg.isPresent());
372 CPPUNIT_ASSERT(!verboseArg.isPresent());
373 CPPUNIT_ASSERT(parser.noColorArg().isPresent());
374 CPPUNIT_ASSERT_EQUAL(1_st, fileArg.values(0).size());
375 CPPUNIT_ASSERT_EQUAL(
"test-v"sv, std::string_view(fileArg.values(0).front()));
378 const char *argv8[] = {
"tageditor" };
380 parser.parseArgs(1, argv8, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
381 CPPUNIT_ASSERT(qtConfigArgs.qtWidgetsGuiArg().isPresent());
382 CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
383 CPPUNIT_ASSERT(!verboseArg.isPresent());
384 CPPUNIT_ASSERT(!displayTagInfoArg.isPresent());
385 CPPUNIT_ASSERT(!filesArg.isPresent());
386 CPPUNIT_ASSERT(!fileArg.isPresent());
387 if (
const auto path = std::getenv(
"PATH")) {
388 CPPUNIT_ASSERT(fileArg.firstValue());
389 CPPUNIT_ASSERT_EQUAL(std::string_view(path), std::string_view(fileArg.firstValue()));
391 CPPUNIT_ASSERT(!fileArg.firstValue());
395 const char *argv13[] = {
"tageditor",
"get",
"--fields",
"album=test",
"title",
"diskpos",
"--files",
"somefile" };
396 verboseArg.setRequired(
false);
398 parser.parseArgs(8, argv13, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
400 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
401 CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
402 CPPUNIT_ASSERT(!verboseArg.isPresent());
403 CPPUNIT_ASSERT(displayTagInfoArg.isPresent());
404 CPPUNIT_ASSERT(fieldsArg.isPresent());
405 CPPUNIT_ASSERT_EQUAL(
"album=test"sv, std::string_view(fieldsArg.values().at(0)));
406 CPPUNIT_ASSERT_EQUAL(
"title"sv, std::string_view(fieldsArg.values().at(1)));
407 CPPUNIT_ASSERT_EQUAL(
"diskpos"sv, std::string_view(fieldsArg.values().at(2)));
408 CPPUNIT_ASSERT_EQUAL(3_st, fieldsArg.values().size());
409 CPPUNIT_ASSERT(filesArg.isPresent());
410 CPPUNIT_ASSERT_EQUAL(
"somefile"sv, std::string_view(filesArg.values().at(0)));
411 CPPUNIT_ASSERT(!notAlbumArg.isPresent());
414 const char *argv9[] = {
"tageditor",
"-p",
"album",
"title",
"diskpos" };
415 fieldsArg.setRequiredValueCount(4);
418 parser.parseArgs(5, argv9, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
419 CPPUNIT_FAIL(
"Exception expected.");
421 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
422 CPPUNIT_ASSERT_EQUAL(
423 "Not all parameters for argument \"fields\" provided. You have to provide the following parameters: title album artist trackpos"sv,
424 std::string_view(e.what()));
428 const char *argv16[] = {
"tageditor",
"--hel",
"-p",
"album",
"title",
"diskpos" };
432 parser.parseArgs(6, argv16, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
433 CPPUNIT_FAIL(
"Exception expected.");
435 CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
436 CPPUNIT_ASSERT_EQUAL(
"The specified argument \"--hel\" is unknown.\nDid you mean --help or get?"sv, std::string_view(e.what()));
440 const char *argv14[] = {
"tageditor",
"get",
"fields",
"album=test",
"-f",
"somefile" };
442 fieldsArg.setDenotesOperation(
true);
443 parser.parseArgs(6, argv14, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
444 CPPUNIT_ASSERT(displayTagInfoArg.isPresent());
445 CPPUNIT_ASSERT(fieldsArg.isPresent());
446 CPPUNIT_ASSERT_EQUAL(
"album=test"sv, std::string_view(fieldsArg.values().at(0)));
450 fieldsArg.setDenotesOperation(
false);
451 parser.parseArgs(6, argv14, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
452 CPPUNIT_ASSERT(displayTagInfoArg.isPresent());
453 CPPUNIT_ASSERT(fieldsArg.isPresent());
454 CPPUNIT_ASSERT_EQUAL(
"fields"sv, std::string_view(fieldsArg.values().at(0)));
455 CPPUNIT_ASSERT_EQUAL(
"album=test"sv, std::string_view(fieldsArg.values().at(1)));
458 const char *argv19[] = {
"tageditor",
"get",
"--fields",
"foo",
"bar",
"--help" };
461 parser.parseArgs(6, argv19, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
462 CPPUNIT_FAIL(
"Exception expected.");
464 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"--help assumed to be an argument without greedy-flag (leading to error)",
465 "The argument \"help\" can not be combined with \"get\"."sv, std::string_view(e.what()));
468 fieldsArg.setFlags(Argument::Flags::Greedy,
true);
469 parser.parseArgs(6, argv19, ParseArgumentBehavior::CheckConstraints | ParseArgumentBehavior::InvokeCallbacks);
470 CPPUNIT_ASSERT(displayTagInfoArg.isPresent());
471 CPPUNIT_ASSERT(fieldsArg.isPresent());
472 CPPUNIT_ASSERT_MESSAGE(
"--help not considered an argument with greedy-flag", !parser.helpArg().isPresent());
473 CPPUNIT_ASSERT_EQUAL(
"foo"sv, std::string_view(fieldsArg.values().at(0)));
474 CPPUNIT_ASSERT_EQUAL(
"bar"sv, std::string_view(fieldsArg.values().at(1)));
475 CPPUNIT_ASSERT_EQUAL(
"--help"sv, std::string_view(fieldsArg.values().at(2)));
476 CPPUNIT_ASSERT_EQUAL(3_st, fieldsArg.values().size());
529 parser.
setExitFunction(std::bind(&ArgumentParserTests::failOnExit,
this, std::placeholders::_1));
530 Argument verboseArg(
"verbose",
'v',
"be verbose");
532 Argument filesArg(
"files",
'f',
"specifies the path of the file(s) to be opened");
535 Argument nestedSubArg(
"nested-sub",
'\0',
"nested sub arg");
536 Argument subArg(
"sub",
'\0',
"sub arg");
538 Argument displayFileInfoArg(
"display-file-info",
'i',
"displays general file information");
540 displayFileInfoArg.
setSubArguments({ &filesArg, &verboseArg, &subArg });
541 Argument fieldsArg(
"fields",
'\0',
"specifies the fields");
545 Argument valuesArg(
"values",
'\0',
"specifies the fields");
549 valuesArg.
setValueCompletionBehavior(ValueCompletionBehavior::PreDefinedValues | ValueCompletionBehavior::AppendEquationSign);
550 Argument selectorsArg(
"selectors",
'\0',
"has some more pre-defined values");
557 Argument getArg(
"get",
'g',
"gets tag values");
559 Argument setArg(
"set",
's',
"sets tag values");
565 const char *
const argv1[] = {
"se" };
569 CPPUNIT_ASSERT(reader.
read());
570 parser.printBashCompletion(1, argv1, 0, reader);
579 parser.printBashCompletion(1, argv1, 0, reader);
583 const char *
const argv2[] = {
"set" };
588 parser.printBashCompletion(1, argv2, 0, reader);
594 const OutputCheck c(
"COMPREPLY=('--files' '--no-color' '--selectors' '--values' )\n");
596 parser.printBashCompletion(1, argv2, 1, reader);
603 const OutputCheck c(
"COMPREPLY=('files' '--no-color' '--selectors' '--values' )\n");
605 parser.printBashCompletion(1, argv2, 1, reader);
612 const OutputCheck c(
"COMPREPLY=('display-file-info' 'get' 'set' '--help' '--no-color' )\n");
614 parser.printBashCompletion(0,
nullptr, 0, reader);
618 const char *
const argv3[] = {
"get",
"--fields" };
621 const OutputCheck c(
"COMPREPLY=('title' 'album' 'artist' 'trackpos' '--files' '--no-color' )\n");
623 parser.printBashCompletion(2, argv3, 2, reader);
627 const char *
const argv4[] = {
"set",
"--values",
"a" };
630 const OutputCheck c(
"COMPREPLY=('album=' 'artist=' ); compopt -o nospace\n");
632 parser.printBashCompletion(3, argv4, 2, reader);
636 const char *
const argv12[] = {
"set",
"--selectors",
"tag=id3" };
639 const OutputCheck c(
"COMPREPLY=('tag=id3v1' 'tag=id3v2' )\n");
641 parser.printBashCompletion(3, argv12, 2, reader);
645 const char *
const argv13[] = {
"set",
"--selectors",
"tag",
"=",
"id3" };
648 const OutputCheck c(
"COMPREPLY=('id3v1' 'id3v2' )\n");
650 parser.printBashCompletion(5, argv13, 4, reader);
654 const OutputCheck c(
"COMPREPLY=('id3v1' 'id3v2' 'matroska' )\n");
656 parser.printBashCompletion(5, argv13, 3, reader);
663 const OutputCheck c(
"COMPREPLY=('matroska' 'mp4' 'vorbis' )\n");
665 parser.printBashCompletion(5, argv13, 3, reader);
671 const OutputCheck c(
"COMPREPLY=('title' 'album' 'artist' 'trackpos' '--fields' '--files' '--no-color' )\n");
673 parser.printBashCompletion(1, argv3, 2, reader);
678 iniFilePath.resize(iniFilePath.size() - 4);
680 mkvFilePath.resize(mkvFilePath.size() - 17);
682 const char *
const argv5[] = {
"get",
"--files", iniFilePath.c_str() };
684#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
686 const OutputCheck c(
"COMPREPLY=('" % mkvFilePath %
" '\"'\"'with quote'\"'\"'.mkv' '" % iniFilePath +
".ini' ); compopt -o filenames\n",
687 "COMPREPLY=('" % iniFilePath %
".ini' '" % mkvFilePath +
" '\"'\"'with quote'\"'\"'.mkv' ); compopt -o filenames\n");
692 parser.printBashCompletion(3, argv5, 2, reader);
697 directoryPath.resize(directoryPath.size() - 4);
700 const char *
const argv14[] = {
"get",
"--files", directoryPath.c_str() };
702#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
703 const OutputCheck c(
"COMPREPLY=('" % directoryPath +
"' ); compopt -o filenames\n");
708 parser.printBashCompletion(3, argv14, 2, reader);
712 const char *
const argv6[] = {
"set",
"--" };
715 const OutputCheck c(
"COMPREPLY=('--files' '--no-color' '--selectors' '--values' )\n");
717 parser.printBashCompletion(2, argv6, 1, reader);
721 const char *
const argv7[] = {
"-i",
"--sub",
"--" };
724 const OutputCheck c(
"COMPREPLY=('--files' '--nested-sub' '--no-color' '--verbose' )\n");
726 parser.printBashCompletion(3, argv7, 2, reader);
730 const char *
const argv8[] = {
"set",
"--values",
"t" };
733 const OutputCheck c(
"COMPREPLY=('title=' 'trackpos=' ); compopt -o nospace\n");
735 parser.printBashCompletion(3, argv8, 2, reader);
739 const char *
const argv9[] = {
"-gf" };
744 parser.printBashCompletion(1, argv9, 0, reader);
748 const OutputCheck c([](
const string &actualOutput) { CPPUNIT_ASSERT_EQUAL(0_st, actualOutput.find(
"COMPREPLY=('--fields' ")); });
750 parser.printBashCompletion(1, argv9, 1, reader);
757 const char *
const argv10[] = {
"/some/path/tageditor",
"--bash-completion-for",
"0" };
760 const OutputCheck c(
"COMPREPLY=('display-file-info' 'get' 'set' '--help' '--no-color' )\n");
763 CPPUNIT_ASSERT(!strcmp(
"/some/path/tageditor", parser.
executable()));
764 CPPUNIT_ASSERT(exitCalled);
767 const char *
const argv11[] = {
"/some/path/tageditor",
"--bash-completion-for",
"ge" };