From 44b72ab11e1da33aeb9df65797dcfc9b7935f392 Mon Sep 17 00:00:00 2001
From: Thomas Hallgren
Date: Wed, 10 Mar 2010 12:22:24 +0000
Subject: 304855 : [query] add a query command to p2 console
---
.../internal/p2/console/ProvCommandProvider.java | 71 ++++++++++++++++++++++
1 file changed, 71 insertions(+)
(limited to 'bundles/org.eclipse.equinox.p2.console/src')
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
index 3b105b1fa..3024d1185 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
@@ -236,6 +236,36 @@ public class ProvCommandProvider implements CommandProvider {
println(interpreter, units[i]);
}
+ /**
+ * Lists the installable units that match the given URL and query. A third
+ * boolean argument can be provided where true
means "full query"
+ * and false
means "e;match query"e;. The default is false
.
+ *
+ * @param interpreter
+ */
+ public void _provlquery(CommandInterpreter interpreter) {
+ String urlString = processArgument(interpreter.nextArgument());
+ String expression = processArgument(interpreter.nextArgument());
+ if (expression == null) {
+ interpreter.println("Please enter a query");
+ return;
+ }
+ boolean useFull = Boolean.valueOf(processArgument(interpreter.nextArgument())).booleanValue();
+ URI repoURL = null;
+ if (urlString != null && !urlString.equals(WILDCARD_ANY))
+ repoURL = toURI(interpreter, urlString);
+
+ IQuery query = useFull ? QueryUtil.createQuery(expression) : QueryUtil.createMatchQuery(expression);
+ IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoURL, query, null));
+ // Now print out results
+ if (units.length == 0)
+ interpreter.println("No units found");
+ else {
+ for (int i = 0; i < units.length; i++)
+ println(interpreter, units[i]);
+ }
+ }
+
/**
* Lists the known metadata repositories, or the contents of a given
* metadata repository.
@@ -474,7 +504,44 @@ public class ProvCommandProvider implements CommandProvider {
// Now print out results
for (int i = 0; i < units.length; i++)
println(interpreter, units[i]);
+ }
+
+ /**
+ * Lists the installable units that match the given profile id and query. The id can be
+ * "this" to denote the self profile. A third boolean argument can be provided
+ * where true
means "full query" and false
means
+ * "e;match query"e;. The default is false
.
+ *
+ * @param interpreter
+ */
+ public void _provlpquery(CommandInterpreter interpreter) {
+ String profileId = processArgument(interpreter.nextArgument());
+ if (profileId == null || profileId.equals("this")) {
+ profileId = IProfileRegistry.SELF;
+ }
+
+ String expression = processArgument(interpreter.nextArgument());
+ if (expression == null) {
+ interpreter.println("Please enter a query");
+ return;
+ }
+
+ boolean useFull = Boolean.valueOf(processArgument(interpreter.nextArgument())).booleanValue();
+ IQuery query = useFull ? QueryUtil.createQuery(expression) : QueryUtil.createMatchQuery(expression);
+ IProfile profile = ProvisioningHelper.getProfile(agent, profileId);
+ if (profile == null) {
+ interpreter.println("Profile " + profileId + " not found");
+ return;
+ }
+ IInstallableUnit[] units = sort(profile.query(query, new NullProgressMonitor()));
+ // Now print out results
+ if (units.length == 0)
+ interpreter.println("No units found");
+ else {
+ for (int i = 0; i < units.length; i++)
+ println(interpreter, units[i]);
+ }
}
public void _provremove(CommandInterpreter interpreter) {
@@ -573,6 +640,8 @@ public class ProvCommandProvider implements CommandProvider {
help.append(NEW_LINE);
help.append("\tprovliu [ ] - Lists the IUs that match the pattern in the given repo. * matches all");
help.append(NEW_LINE);
+ help.append("\tprovlquery [ true | false ] - Lists the IUs that match the query expression in the given repo. * matches all. The expression is expected to be a boolean match expression unless the third argument is true, in which case the expression is a full query");
+ help.append(NEW_LINE);
help.append("---");
help.append("Profile Registry Commands");
@@ -589,6 +658,8 @@ public class ProvCommandProvider implements CommandProvider {
help.append(NEW_LINE);
help.append("\tprovlpts [] - Lists timestamps for given profile, or if no profileid given then the default profile timestamps are reported");
help.append(NEW_LINE);
+ help.append("\tprovlpquery [ true | false ] - Lists the IUs that match the query expression in the given profile. The expression is expected to be a boolean match expression unless the third argument is true, in which case the expression is a full query");
+ help.append(NEW_LINE);
help.append("---");
help.append("Install Commands");
--
cgit v1.2.3