From 63274c95a3d78fbed8f511690cf7b248a6231273 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 17 Mar 2016 12:48:38 +0100 Subject: Add QCommandLineOption::Flags containing HiddenFromHelp and ShortOptionStyle This patch adds a new option, QCommandLineOption::ShortOptionStyle, which helps applications (such as compilers, so moc and now qdoc) which need to mix long-style and short flags. [ChangeLog][QtCore][QCommandLineOption] Added flags() and setFlags() methods. Added ShortOptionStyle and HiddenFromHelp flags. Change-Id: I944ce56aff2b28ecd6bb9d2d23c4e726e9d06647 Reviewed-by: Marc Mutz --- .../tools/qcommandlineparser/tst_qcommandlineparser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp') diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index f3f335cb92..fd835daa3a 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -450,6 +450,13 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes_data() << QStringList("abc") << QStringList("val"); QTest::newRow("implicitlylong_with_space") << QCommandLineParser::ParseAsCompactedShortOptions << (QStringList() << "-c" << "val") << QStringList("c") << QStringList("val"); + + QTest::newRow("forceshort_detached") << QCommandLineParser::ParseAsLongOptions << (QStringList() << "-I" << "45") + << QStringList("I") << QStringList("45"); + QTest::newRow("forceshort_attached") << QCommandLineParser::ParseAsLongOptions << (QStringList() << "-I46") + << QStringList("I") << QStringList("46"); + QTest::newRow("forceshort_mixed") << QCommandLineParser::ParseAsLongOptions << (QStringList() << "-I45" << "-nn") + << (QStringList() << "I" << "nn") << QStringList("45"); } void tst_QCommandLineParser::testSingleDashWordOptionModes() @@ -468,6 +475,10 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes() parser.addOption(QCommandLineOption("b", QStringLiteral("b option."))); parser.addOption(QCommandLineOption(QStringList() << "c" << "abc", QStringLiteral("c option."), QStringLiteral("value"))); parser.addOption(QCommandLineOption("nn", QStringLiteral("nn option."))); + QCommandLineOption forceShort(QStringLiteral("I"), QStringLiteral("always short option"), + QStringLiteral("path"), QStringLiteral("default")); + forceShort.setFlags(QCommandLineOption::ShortOptionStyle); + parser.addOption(forceShort); QVERIFY(parser.parse(commandLine)); QCOMPARE(parser.optionNames(), expectedOptionNames); for (int i = 0; i < expectedOptionValues.count(); ++i) -- cgit v1.2.3