summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLazar Kirchev2011-10-12 10:32:45 (EDT)
committerLazar Kirchev2011-10-12 10:32:45 (EDT)
commit0a9412fb9b79504adcfea4ce990cef03b2d958a7 (patch)
tree3d29686eb6a26185231b21c86ac7ce6460af2a42
parentab8463e3c0066498fd179ab073d0a6367f80984f (diff)
downloadrt.equinox.incubator-0a9412fb9b79504adcfea4ce990cef03b2d958a7.zip
rt.equinox.incubator-0a9412fb9b79504adcfea4ce990cef03b2d958a7.tar.gz
rt.equinox.incubator-0a9412fb9b79504adcfea4ce990cef03b2d958a7.tar.bz2
Fix help command
-rw-r--r--console/org.eclipse.equinox.console.supportability/src/org/eclipse/equinox/console/commands/HelpCommand.java65
1 files changed, 36 insertions, 29 deletions
diff --git a/console/org.eclipse.equinox.console.supportability/src/org/eclipse/equinox/console/commands/HelpCommand.java b/console/org.eclipse.equinox.console.supportability/src/org/eclipse/equinox/console/commands/HelpCommand.java
index a1ca8f0..f034dc4 100644
--- a/console/org.eclipse.equinox.console.supportability/src/org/eclipse/equinox/console/commands/HelpCommand.java
+++ b/console/org.eclipse.equinox.console.supportability/src/org/eclipse/equinox/console/commands/HelpCommand.java
@@ -23,6 +23,7 @@ import org.apache.felix.service.command.CommandSession;
import org.eclipse.equinox.console.command.adapter.CustomCommandInterpreter;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
@@ -105,23 +106,13 @@ public class HelpCommand {
* @throws Exception
*/
public void help(final CommandSession session, String... args) throws Exception {
- boolean isLegacy = false;
- boolean isAll = false;
String command = null;
if (args.length > 0) {
- for (String arg : args) {
- if (arg.equals("-legacy")) {
- isLegacy = true;
- } else if(arg.equals("-all")) {
- isAll = true;
- } else {
- command = arg;
- }
- }
+ command = args[0];
}
- if (isLegacy == true && command != null) {
+ if (command != null) {
for (CommandProvider provider : legacyCommandProviders) {
Method[] methods = provider.getClass().getMethods();
for (Method method : methods) {
@@ -144,36 +135,52 @@ public class HelpCommand {
}
}
}
+
+ try {
+ session.execute("felix:help " + command);
+ } catch (IllegalArgumentException e) {
+ handleCommandNotFound();
+ }
+
return;
}
-
- if (isLegacy == false && command != null) {
- session.execute("felix:help " + command);
- return;
- }
-
- if (isLegacy == true) {
- printLegacyCommands();
- return;
- }
-
- if (isAll == true) {
- printLegacyCommands();
+
+ printLegacyCommands();
+ try {
session.execute("felix:help");
- return;
+ } catch (IllegalArgumentException e) {
+ handleCommandNotFound();
}
-
- session.execute("felix:help");
+
}
private void printLegacyCommands() {
for (CommandProvider provider : legacyCommandProviders) {
Method[] methods = provider.getClass().getMethods();
for (Method method : methods) {
- if (method.getName().startsWith("_")) {
+ if (method.getName().startsWith("_") && !method.getName().equals("_help")) {
System.out.println("equinox:" + method.getName().substring(1));
}
}
}
}
+
+ private boolean checkStarted(String symbolicName) {
+ Bundle[] bundles = context.getBundles();
+ for (Bundle bundle : bundles) {
+ if (bundle.getSymbolicName().equals(symbolicName) && bundle.getState() == Bundle.ACTIVE) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private void handleCommandNotFound() {
+ if (checkStarted("org.apache.felix.gogo.command")) {
+ System.out.println("Cannot find felix:help command");
+ } else {
+ System.out.println("Cannot find felix:help command; bundle org.apache.felix.gogo.command is not started");
+ }
+ }
}