diff options
author | Tobias Hunger <tobias.hunger@digia.com> | 2013-02-07 10:42:24 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@digia.com> | 2013-02-07 12:16:45 +0100 |
commit | 56582e8c06ad0fb29e252a72a904bf481dd9e2c6 (patch) | |
tree | 68608d46cf81b10e4d287ebf9866d9b98a58e23d /src/tools/sdktool/addtoolchainoperation.cpp | |
parent | c8a34f05a059941a88725268246c3301c673a8fe (diff) |
SDKtool: Fix return values and improve error reporting
Change-Id: I1a44a39d5cd96be48608fdb4fab252a51046971e
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/tools/sdktool/addtoolchainoperation.cpp')
-rw-r--r-- | src/tools/sdktool/addtoolchainoperation.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/tools/sdktool/addtoolchainoperation.cpp b/src/tools/sdktool/addtoolchainoperation.cpp index 1f0240c5c6..45351ae392 100644 --- a/src/tools/sdktool/addtoolchainoperation.cpp +++ b/src/tools/sdktool/addtoolchainoperation.cpp @@ -66,10 +66,10 @@ QString AddToolChainOperation::helpText() const QString AddToolChainOperation::argumentsHelpText() const { - return QLatin1String(" --id <ID> id of the new tool chain.\n" - " --name <NAME> display name of the new tool chain.\n" - " --path <PATH> path to the compiler.\n" - " --abi <ABI STRING> ABI of the compiler.\n" + return QLatin1String(" --id <ID> id of the new tool chain (required).\n" + " --name <NAME> display name of the new tool chain (required).\n" + " --path <PATH> path to the compiler (required).\n" + " --abi <ABI STRING> ABI of the compiler (required).\n" " --supportedAbis <ABI STRING>,<ABI STRING> list of ABIs supported by the compiler.\n" " <KEY> <TYPE:VALUE> extra key value pairs\n"); } @@ -80,58 +80,66 @@ bool AddToolChainOperation::setArguments(const QStringList &args) const QString current = args.at(i); const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString(); + if (next.isNull() && current.startsWith(QLatin1String("--"))) { + std::cerr << "No parameter for option '" << qPrintable(current) << "' given." << std::endl << std::endl; + return false; + } + if (current == QLatin1String("--id")) { - if (next.isNull()) - return false; ++i; // skip next; m_id = next; continue; } if (current == QLatin1String("--name")) { - if (next.isNull()) - return false; ++i; // skip next; m_displayName = next; continue; } if (current == QLatin1String("--path")) { - if (next.isNull()) - return false; ++i; // skip next; m_path = next; continue; } if (current == QLatin1String("--abi")) { - if (next.isNull()) - return false; ++i; // skip next; m_targetAbi = next; continue; } if (current == QLatin1String("--supportedAbis")) { - if (next.isNull()) - return false; ++i; // skip next; m_supportedAbis = next; continue; } - if (next.isNull()) + if (next.isNull()) { + std::cerr << "No value given for key '" << qPrintable(current) << "'."; return false; + } ++i; // skip next; KeyValuePair pair(current, next); - if (!pair.value.isValid()) + if (!pair.value.isValid()) { + std::cerr << "Value for key '" << qPrintable(current) << "' is not valid."; return false; + } m_extra << pair; } if (m_supportedAbis.isEmpty()) m_supportedAbis = m_targetAbi; + if (m_id.isEmpty()) + std::cerr << "No id given for tool chain." << std::endl; + if (m_displayName.isEmpty()) + std::cerr << "No name given for tool chain." << std::endl; + if (m_path.isEmpty()) + std::cerr << "No path given for tool chain." << std::endl; + if (m_targetAbi.isEmpty()) + std::cerr << "No target abi given for tool chain." << std::endl; + return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_path.isEmpty() && !m_targetAbi.isEmpty(); } |