diff options
author | Thomas Hallgren | 2010-03-10 12:22:24 +0000 |
---|---|---|
committer | Thomas Hallgren | 2010-03-10 12:22:24 +0000 |
commit | 44b72ab11e1da33aeb9df65797dcfc9b7935f392 (patch) | |
tree | d85d6514b8f2895191cf7622d4a528975d0761dc /bundles/org.eclipse.equinox.p2.console/src | |
parent | 4e96bdc386990553957b3a1e98242889a0743de2 (diff) | |
download | rt.equinox.p2-44b72ab11e1da33aeb9df65797dcfc9b7935f392.tar.gz rt.equinox.p2-44b72ab11e1da33aeb9df65797dcfc9b7935f392.tar.xz rt.equinox.p2-44b72ab11e1da33aeb9df65797dcfc9b7935f392.zip |
304855 : [query] add a query command to p2 console
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.console/src')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java | 71 |
1 files changed, 71 insertions, 0 deletions
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 @@ -237,6 +237,36 @@ public class ProvCommandProvider implements CommandProvider { } /** + * Lists the installable units that match the given URL and query. A third + * boolean argument can be provided where <code>true</code> means "full query" + * and <code>false</code> means "e;match query"e;. The default is <code>false</code>. + * + * @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<IInstallableUnit> 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 <code>true</code> means "full query" and <code>false</code> means + * "e;match query"e;. The default is <code>false</code>. + * + * @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<IInstallableUnit> 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 [<repository URI | *> <iu id | *> <version range | *>] - Lists the IUs that match the pattern in the given repo. * matches all"); help.append(NEW_LINE); + help.append("\tprovlquery <repository URI | *> <expression> [ 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 [<profileid>] - Lists timestamps for given profile, or if no profileid given then the default profile timestamps are reported"); help.append(NEW_LINE); + help.append("\tprovlpquery <profileid | this> <expression> [ 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"); |