diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2012-12-11 12:59:37 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2012-12-11 13:49:32 +0100 |
commit | 3ae3304c258d836451553cb15092e68000185812 (patch) | |
tree | 584fde12cfddcfc6dcdda3798c3726edca00fb1e | |
parent | 28c29aba78252ab9d37e8c82999578553ea6cf24 (diff) |
Allow "-h" or "--help" to get general help.
These don't really fit into our syntax, but because of the "default
command" feature, people would get surprising output for them
if they were not supported (namely, the build-specific help).
Change-Id: I50dc69679803aaeec5937fbf5f8df492f1928180
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r-- | src/app/qbs/parser/commandlineparser.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp index dd28de317..3a3262181 100644 --- a/src/app/qbs/parser/commandlineparser.cpp +++ b/src/app/qbs/parser/commandlineparser.cpp @@ -228,8 +228,16 @@ void CommandLineParser::CommandLineParserPrivate::doParse() try { command = commandFromString(commandLine.first()); commandLine.removeFirst(); - } catch (const Error &) { // No command given, use default. - command = commandPool.getCommand(BuildCommandType); + } catch (const Error &) { // No command given. + // As an exception to the command-based syntax, we allow -h or --help as the + // sole contents of the command line, because people are used to this working. + if (commandLine.count() == 1 && (commandLine.first() == QLatin1String("-h") + || commandLine.first() == QLatin1String("--help"))) { + command = commandPool.getCommand(HelpCommandType); + commandLine.clear(); + } else { + command = commandPool.getCommand(BuildCommandType); + } } } command->parse(commandLine); |