summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-03-18 15:22:01 +0100
committerDominik Holland <dominik.holland@qt.io>2020-03-20 00:28:31 +0100
commit3276c4feae52ed033be2c2b7b1e15ba3d2dcb470 (patch)
tree8f07c5ad3c6e8ac4e40db2c7c5e03c0e60ea4d0b
parent875f524db55b4a7e9fc40d149429b9a2f9ed6c52 (diff)
downloadqtapplicationmanager-3276c4feae52ed033be2c2b7b1e15ba3d2dcb470.tar.gz
appman-controller: Improve option and help usage
The controller accepts the options for the command now also before the actual command e.g. -ioe debug-application This makes it easier for the user, as this is also the format printed by QCommandLineParser::showHelp() Showing the full help for all commands also when only the specific help for a command should be provided, makes it very hard to see what the correct usage for the command actually is. We now show only a short help when a command is provided and the full help in all other cases. Change-Id: I6927cf465ba1dd46cfbf361af04a3bfc8d089b67 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--src/tools/controller/controller.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tools/controller/controller.cpp b/src/tools/controller/controller.cpp
index 9572f187..89c117b7 100644
--- a/src/tools/controller/controller.cpp
+++ b/src/tools/controller/controller.cpp
@@ -234,7 +234,6 @@ private:
Exception *m_exception = nullptr;
};
-
int main(int argc, char *argv[])
{
QCoreApplication::setApplicationName(qSL("Qt Application Manager Controller"));
@@ -260,7 +259,6 @@ int main(int argc, char *argv[])
" appman-controller <command> --help";
QCommandLineParser clp;
- clp.setApplicationDescription(qSL("\n") + QCoreApplication::applicationName() + qL1S(desc));
clp.addHelpOption();
clp.addVersionOption();
@@ -270,10 +268,10 @@ int main(int argc, char *argv[])
// ignore unknown options for now -- the sub-commands may need them later
clp.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsPositionalArguments);
- if (!clp.parse(QCoreApplication::arguments())) {
- fprintf(stderr, "%s\n", qPrintable(clp.errorText()));
- exit(1);
- }
+ // ignore the return value here, as we also accept options we don't know about yet.
+ // If an option is really not accepted by a command, the comman specific parsing should report
+ // this.
+ clp.parse(QCoreApplication::arguments());
clp.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsOptions);
// REMEMBER to update the completion file util/bash/appman-prompt, if you apply changes below!
@@ -282,8 +280,10 @@ int main(int argc, char *argv[])
case NoCommand:
if (clp.isSet(qSL("version")))
clp.showVersion();
+
+ clp.setApplicationDescription(qSL("\n") + QCoreApplication::applicationName() + qL1S(desc));
if (clp.isSet(qSL("help")))
- clp.showHelp();
+ clp.showHelp(0);
clp.showHelp(1);
break;