summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qcommandlineparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QCommandLineParser: add parsing mode for options after argumentsDavid Faure2015-03-061-3/+44
| | | | | | | | | | | | | | | | | The new mode, ParseAsPositionalArguments, allows to interpret "application argument --opt" as having two positional arguments, "argument" and "--opt". This mode is useful for executables that aim to launch other executables (e.g. wrappers, debugging tools, etc.) or who support internal commands followed by options for the command. "argument" is the name of the command, and all options occurring after it can be collected and parsed by another command line parser, possibly in another executable. [ChangeLog][QtCore][QCommandLineParser] Add parsing mode for options after arguments, to allow treating them as more arguments. Change-Id: I48d5fcf90f2f59deda8422538b8ebf2680fae828 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommandLineParser: add support for hiding options from --help.David Faure2015-02-231-0/+2
| | | | | | | | | [ChangeLog][QtCore][QCommandLineParser] Added support for hiding options from the --help output, with QCommandLineOption::setHidden(true). Task-number: QTBUG-44298 Change-Id: I62cc2a55428365c0bcc79d2e47c72c0c92104e74 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.4' into devSimon Hausmann2014-12-181-3/+5
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.h src/platformsupport/platformcompositor/qopenglcompositor.cpp src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp tests/auto/gui/kernel/qwindow/tst_qwindow.cpp Change-Id: I5422868500be695584a496dbbbc719d146bc572d
| * Doc: corrected documentation addOptions()Nico Vertriest2014-12-121-3/+5
| | | | | | | | | | | | Task-number: QTBUG-43259 Change-Id: If27c0658f7abaa4ce01de343ce90c14bd911212f Reviewed-by: Martin Smith <martin.smith@digia.com>
* | QCommandLineParser: Show usage and errors in message boxes on Windows.Friedemann Kleint2014-11-271-20/+48
|/ | | | | | | | | | | Use the Windows MessageBox API if no console window can be obtained. [ChangeLog][QtCore][QCommandLineParser] Message boxes are used to display errors and usage if no console window can be obtained on Windows. Change-Id: I63ee8e4d8bd78db83e688fd69374779102562aa3 Reviewed-by: David Faure <david.faure@kdab.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* QCommandLineParser: support extremely concise option configuration in C++11Marc Mutz2014-08-061-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this commit to make the code in the test work: QCommandLineParser parser; parser.addOptions({ { "a", "The A option." }, { { "v", "verbose" }, "The verbose option." }, { { "i", "infile" }, "The input file.", "value" }, }); For this, QCommandLineParser needs a version of addOption that can take a list of options. That's what addOptions() is for. More importantly, the QCommandLineOption ctors mustn't be explicit. OTOH, any implicit conversion from QString or QStringList to QCommandLineOption is also undesirable. To solve this dilemma, add new QCommandLineOption ctors that just take one argument and are explicit, and make the existing ctors implicit. In order to avoid ambiguities, remove the default values of their resp. 2nd arguments. The new ctors are by intention not \since 5.4, as they are completely transparent to the user. Et voila, even better than getopt_long(3). [ChangeLog][QtCore][QCommandLineParser] Added addOptions() method. Change-Id: I5e779f3406cd0f6c8ec6ecbf6c8074af226de300 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-03-241-0/+72
|\ | | | | | | | | | | | | Conflicts: src/gui/image/qjpeghandler.cpp Change-Id: I9db3acea7d5c82f5da679c8eaeb29431136665f0
| * Use QCommandLineParser in example dnslookup.Friedemann Kleint2014-03-151-0/+72
| | | | | | | | | | | | | | | | | | | | | | Show how use QCommandLineParser with additional parameter checking for custom options and positional arguments. Also explain how to display help in GUI applications. Change-Id: I03513e09b7dd5b150259593da0af2ef2a281cab2 Reviewed-by: David Faure <david.faure@kdab.com>
* | Add QCommandLineParser::showVersion(), similar to showHelp().David Faure2014-03-141-4/+18
|/ | | | | | Change-Id: I1782c226ee8c457a68eb9ae9948a2a6a700d7a52 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Make QCommandLineParser not crash if passed a bad QCommandLineOptionThiago Macieira2014-01-161-1/+2
| | | | | | | | | | | This otherwise crashed: QCommandLineOotion opt("with=equals"); parser.isSet(opt); Can't write a unit test because it produces a warning. Change-Id: Ifc67f20bb4b16b96d93dffbe4e82e6cc8a17584d Reviewed-by: David Faure <david.faure@kdab.com>
* QCommandLineParser: pluck some low-hanging fruit re: exception safetyMarc Mutz2013-12-061-2/+2
| | | | | | | | | | | | | | | | | Make QCommandLineParser::add{Help,Version}Option() QCommandLineOption::setDefaultValue() QCommandLineOptionPrivate::setNames() have transaction semantics: either they succeed, or they change nothing. It's trivial to provide this guarantee, so do it. Add a test for the surprising property that setDefaultValue("") resets defaultValues() to an empty QStringList instead of one that contains the empty string. Change-Id: I61623019de3c7d2e52c24f42cc2e23ec5fddc4da Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommandLineParser: add word-wrapping algorithmDavid Faure2013-11-171-5/+44
| | | | | | | | Rather than breaking at column 79 precisely, break entire words, to improve readability. Change-Id: Ie30db00f0e6ed95cce87480c3b91804826c6076b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-8/+8
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* QCommandLineParser: improve implementationDavid Faure2013-09-101-11/+9
| | | | | | | Based on feedback from Thiago. Change-Id: I9a3ce0b90b5d1d680c66351d421874effbd426f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommandLineParser: improve documentationDavid Faure2013-09-101-29/+43
| | | | | | | Based on feedback from Thiago Change-Id: I8912447197e636732e5b8ac37e77d18b54e9b43d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live QCommandLineParser!David Faure2013-08-241-0/+896
The QCommandLineParser class provides a means for handling the command line options. QCoreApplication provides the command-line arguments as a simple list of strings. QCommandLineParser provides the ability to define a set of options, parse the command-line arguments, and store which options have actually been used, as well as option values. Done-with: Laszlo Papp <lpapp@kde.org> Change-Id: Ic7bebc10b3f8d8dd06ad0f4bb897c51d566e3b7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>