ServiceReference ref = m_context.getServiceReference(
org.apache.felix.shell.ShellService.class.getName());
if (ref != null)
{
ShellService ss = (ShellService) m_context.getService(ref);
// Parse command line.
StringTokenizer st = new StringTokenizer(s, " ");
// Ignore the command name.
st.nextToken();
if (!st.hasMoreTokens())
{
String[] cmds = ss.getCommands();
for (int i = 0; i < cmds.length; i++)
{
out.println(cmds[i]);
}
out.println("\nUse 'help <command-name>' for more information.");
}
else
{
String[] cmds = ss.getCommands();
String[] targets = new String[st.countTokens()];
for (int i = 0; i < targets.length; i++)
{
targets[i] = st.nextToken().trim();
}
boolean found = false;
for (int cmdIdx = 0; (cmdIdx < cmds.length); cmdIdx++)
{
for (int targetIdx = 0; targetIdx < targets.length; targetIdx++)
{
if (cmds[cmdIdx].equals(targets[targetIdx]))
{
if (found)
{
out.println("---");
}
found = true;
out.println("Command : "
+ cmds[cmdIdx]);
out.println("Usage : "
+ ss.getCommandUsage(cmds[cmdIdx]));
out.println("Description : "
+ ss.getCommandDescription(cmds[cmdIdx]));
}
}
}
}
}