}
}
return 0;
}
String name = context.getArgument(index++);
ServiceComponent sc = getServiceForName(registry, name);
if (sc == null) {
if (verbose) {
context.err.println("could not find service '" + name + "'");
return 1;
}
return 0;
}
if (context.getArgumentCount() == index) {
context.out.printf(" %-20s %s\n", sc.getName(), sc.getStatus());
return 0;
}
String operation = context.getArgument(index);
if ("start".equals(operation)) {
if (sc.getStatus() == ServiceComponent.Status.STARTED) {
context.out.println("service " + sc.getName() + " already started");
} else {
sc.start();
context.out.println("service " + sc.getName() + " started");
}
return 0;
}
if ("stop".equals(operation)) {
if (sc.getStatus() == ServiceComponent.Status.STOPPED) {
context.out.println("service " + sc.getName() + " already stopped");
} else {
sc.stop();
context.out.println("service " + sc.getName() + " stopped");
}
return 0;
}
context.err.println("unknown operation '" + operation + "'");
return 1;