+ protected void help(String[] rawArgs, StringBuilder buf) {
+ String[] args = Arrays.copyOfRange(rawArgs, 1, rawArgs.length);
+ if (args.length == 0) {// modules
+ for (ExecutionModuleDescriptor emd : agent
+ .listExecutionModuleDescriptors()) {
+ appendModule(emd, buf);
+ }
+ } else if (args.length == 1 && !args[0].contains("/")) {// single module
+ NameVersion nameVersion = new BasicNameVersion(args[0]);
+ ExecutionModuleDescriptor emd = agent.getExecutionModuleDescriptor(
+ nameVersion.getName(), nameVersion.getVersion());
+ appendModule(emd, buf);
+
+ // flows
+ for (ExecutionFlowDescriptor efd : emd.getExecutionFlows()) {
+ buf.append(" ").append(efd.getName());
+ if (efd.getDescription() != null
+ && !efd.getDescription().trim().equals(""))
+ buf.append(" : ").append(" ").append(efd.getDescription());
+ buf.append('\n');
+ }
+ return;
+ } else {
+ List<URI> uris = asURIs(args);
+ for (URI uri : uris) {
+ appendUriHelp(uri, buf);
+ }
+ }
+ }
+
+ protected void appendUriHelp(URI uri, StringBuilder buf) {
+ String[] path = uri.getPath().split("/");
+ NameVersion nameVersion = new BasicNameVersion(path[1]);
+ ExecutionModuleDescriptor emd = agent.getExecutionModuleDescriptor(
+ nameVersion.getName(), nameVersion.getVersion());
+
+ StringBuilder flow = new StringBuilder();
+ for (int i = 2; i < path.length; i++)
+ flow.append('/').append(path[i]);
+ String flowPath = flow.toString();
+ ExecutionFlowDescriptor efd = findExecutionFlowDescriptor(emd, flowPath);
+ if (efd == null)
+ throw new SlcException("Flow " + uri + " not found");
+
+ appendModule(emd, buf);
+
+ buf.append(" ").append(efd.getName());
+ if (efd.getDescription() != null
+ && !efd.getDescription().trim().equals(""))
+ buf.append(" : ").append(" ").append(efd.getDescription());
+ buf.append('\n');
+ Map<String, Object> values = DefaultAgent.getQueryMap(uri.getQuery());
+ ExecutionSpec spec = efd.getExecutionSpec();
+ for (String attrKey : spec.getAttributes().keySet()) {
+ ExecutionSpecAttribute esa = spec.getAttributes().get(attrKey);
+ buf.append(" --").append(attrKey);
+ if (values.containsKey(attrKey))
+ buf.append(" ").append(values.get(attrKey));
+ if (esa.getValue() != null)
+ buf.append(" (").append(esa.getValue()).append(')');
+ buf.append('\n');
+ }
+ }
+
+ private void appendModule(ExecutionModuleDescriptor emd, StringBuilder buf) {
+ buf.append("# ").append(emd.getName());
+ if (emd.getDescription() != null
+ && !emd.getDescription().trim().equals(""))
+ buf.append(" : ").append(emd.getDescription());
+ if (emd.getVersion() != null)
+ buf.append(" (v").append(emd.getVersion()).append(")");
+ buf.append('\n');
+ }
+