aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2018-06-20 10:55:15 +0200
committerKai Koehne <kai.koehne@qt.io>2018-06-21 06:27:35 +0000
commit3cc49bc31cffaac1fe70f18bdf25ade312fe4ea9 (patch)
tree28460f89d138d2f7017a942ef88eaaea6ae72201
parent9d859d78bdf4b07ac78782ddcd1905ebf5e49605 (diff)
Give more help in 'No such product' error message
If a user did specify a product that's not available, he most likely wants to see the product names actually available. For up to ten products, we just list the names of the products now. For a longer list of products we point to list-products command. Change-Id: I19ef16b2cf6172f02024d9dfb4c19cb81a5600a3 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/app/qbs/commandlinefrontend.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp
index ae81265ef..d07af0d6f 100644
--- a/src/app/qbs/commandlinefrontend.cpp
+++ b/src/app/qbs/commandlinefrontend.cpp
@@ -346,17 +346,28 @@ CommandLineFrontend::ProductMap CommandLineFrontend::productsToUse() const
const ProjectData projectData = project.projectData();
const auto products = projectData.allProducts();
for (const ProductData &product : products) {
+ productNames << product.name();
if (useAll || m_parser.products().contains(product.name())) {
productList.push_back(product);
- productNames << product.name();
}
}
}
const auto parsedProductNames = m_parser.products();
for (const QString &productName : parsedProductNames) {
- if (!productNames.contains(productName))
- throw ErrorInfo(Tr::tr("No such product '%1'.").arg(productName));
+ if (!productNames.contains(productName)) {
+ QString msg;
+ if (productNames.size() <= 10) {
+ productNames.sort();
+ const QString available = productNames.join(QLatin1String("', '"));
+ msg = Tr::tr("No such product '%1'. "
+ "Available products: '%2'").arg(productName, available);
+ } else {
+ msg = Tr::tr("No such product '%1'. Use 'list-products' to see "
+ "all available products.").arg(productName);
+ }
+ throw ErrorInfo(msg);
+ }
}
return products;