/** * Returns a specified subordinate. * * @param name the subordinate name * @return the subordinate command or null */ public final CommandDescriptor<T> getSubordinate(String name) { return getSubordinates().get(name); }
@Override public void printSynopsisSection(CommandDescriptor<?> descriptor, Appendable stream) throws IOException { man.printSynopsisSection(descriptor, stream); // Extra stream section if (match.getDescriptor().getSubordinates().isEmpty()) { stream.append("STREAM\n"); stream.append(Util.MAN_TAB); printFQN(descriptor, stream); stream.append(" <").append(commandMatch.getConsumedType().getName()).append(", ").append(commandMatch.getProducedType().getName()).append('>'); stream.append("\n\n"); } } };
protected void printSubordinates(CommandDescriptor<?> command, Appendable stream) throws IOException { for (CommandDescriptor<?> subordinate : command.getSubordinates().values()) { stream.append(Util.MAN_TAB).append(subordinate.getName()); String methodText = subordinate.getDescription().getBestEffortMan(); if (methodText.length() > 0) { stream.append("\n"); Util.indent(Util.MAN_TAB_EXTRA, methodText, stream); } stream.append("\n\n"); } }
public void printUsageSection(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append("usage: "); printFQNWithOptions(command, stream); if (command.getSubordinates().size() > 0) { stream.append(" COMMAND [ARGS]"); } else { for (ArgumentDescriptor argument : command.getArguments()) { stream.append(' '); argument.printUsage(stream); } } stream.append("\n\n"); }
public void printSynopsisSection(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append("SYNOPSIS\n"); stream.append(Util.MAN_TAB); printFQNWithOptions(command, stream); if (command.getSubordinates().size() > 0) { stream.append(" COMMAND [ARGS]"); } else { for (ArgumentDescriptor argument : command.getArguments()) { stream.append(' '); argument.printUsage(stream); } } stream.append("\n\n"); }
public void printParametersSection(CommandDescriptor<?> command, Appendable stream) throws IOException { boolean printed = printOptions(false, command, stream); if (command.getSubordinates().size() > 0) { stream.append("COMMANDS\n"); printSubordinates(command, stream); } else { printParameters(printed, command, stream); } }
public void printDetailsSection(CommandDescriptor<?> command, Appendable stream) throws IOException { if (command.getSubordinates().isEmpty()) { List<String[]> tt = collectParametersTuples(command); int length = 0; for (String[] s : tt) { length = Math.max(s[0].length(), length); } String format = " %1$-" + length + "s %2$s\n"; for (String[] tuple : tt) { Formatter formatter = new Formatter(stream); formatter.format(format, tuple[0], tuple[1]); } } else { stream.append("The most commonly used ").append(command.getName()).append(" commands are:\n"); String format = " %1$-16s %2$s\n"; for (CommandDescriptor<?> subordinate : command.getSubordinates().values()) { Formatter formatter = new Formatter(stream); formatter.format(format, subordinate.getName(), subordinate.getUsage()); } } stream.append("\n\n"); } }
@Override public CompletionMatch complete() throws CompletionException { org.crsh.cli.spi.Completion.Builder builder = org.crsh.cli.spi.Completion.builder(prefix); for (CommandDescriptor<?> m : descriptor.getSubordinates().values()) { String name = m.getName(); if (name.startsWith(prefix)) { builder.add(name.substring(prefix.length()), true); } } return new CompletionMatch(delimiter, builder.build()); } }
buffer.append(cmd.describe("", Format.MAN)); buffer.append("----\n"); for (CommandDescriptor<?> m : desc.getSubordinates().values()) { buffer.append("=== ").append(desc.getName()).append(" ").append(m.getName()).append("\n").append("\n"); buffer.append("----\n");
if (owner == null) { add = !(getOptionNames().contains("-h") || getOptionNames().contains("--help")); for (CommandDescriptor<T> sub : delegate.getSubordinates().values()) { if (sub.getOptionNames().contains("-h") || getOptionNames().contains("--help")) { add = false; for (CommandDescriptor<T> subordinate : delegate.getSubordinates().values()) { subordinates.put(subordinate.getName(), new HelpDescriptor<T>(this, subordinate));
/** * Returns a specified subordinate. * * @param name the subordinate name * @return the subordinate command or null */ public final CommandDescriptor<T> getSubordinate(String name) { return getSubordinates().get(name); }
if (foo.getSubordinates().size() > 0) { return new CommandCompletion<T>(foo, s.substring(stop.getIndex()), Delimiter.EMPTY); } else {
public void printUsageSection(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append("usage: "); printFQNWithOptions(command, stream); if (command.getSubordinates().size() > 0) { stream.append(" COMMAND [ARGS]"); } else { for (ArgumentDescriptor argument : command.getArguments()) { stream.append(' '); argument.printUsage(stream); } } stream.append("\n\n"); }
@Override public void printSynopsisSection(CommandDescriptor<?> descriptor, Appendable stream) throws IOException { man.printSynopsisSection(descriptor, stream); // Extra stream section if (match.getDescriptor().getSubordinates().isEmpty()) { stream.append("STREAM\n"); stream.append(Util.MAN_TAB); printFQN(descriptor, stream); stream.append(" <").append(commandMatch.getConsumedType().getName()).append(", ").append(commandMatch.getProducedType().getName()).append('>'); stream.append("\n\n"); } } };
@Override public void printSynopsisSection(CommandDescriptor<?> descriptor, Appendable stream) throws IOException { man.printSynopsisSection(descriptor, stream); // Extra stream section if (match.getDescriptor().getSubordinates().isEmpty()) { stream.append("STREAM\n"); stream.append(Util.MAN_TAB); printFQN(descriptor, stream); stream.append(" <").append(commandMatch.getConsumedType().getName()).append(", ").append(commandMatch.getProducedType().getName()).append('>'); stream.append("\n\n"); } } };
protected void printSubordinates(CommandDescriptor<?> command, Appendable stream) throws IOException { for (CommandDescriptor<?> subordinate : command.getSubordinates().values()) { stream.append(Util.MAN_TAB).append(subordinate.getName()); String methodText = subordinate.getDescription().getBestEffortMan(); if (methodText.length() > 0) { stream.append("\n"); Util.indent(Util.MAN_TAB_EXTRA, methodText, stream); } stream.append("\n\n"); } }
public void printSynopsisSection(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append("SYNOPSIS\n"); stream.append(Util.MAN_TAB); printFQNWithOptions(command, stream); if (command.getSubordinates().size() > 0) { stream.append(" COMMAND [ARGS]"); } else { for (ArgumentDescriptor argument : command.getArguments()) { stream.append(' '); argument.printUsage(stream); } } stream.append("\n\n"); }
public void printParametersSection(CommandDescriptor<?> command, Appendable stream) throws IOException { boolean printed = printOptions(false, command, stream); if (command.getSubordinates().size() > 0) { stream.append("COMMANDS\n"); printSubordinates(command, stream); } else { printParameters(printed, command, stream); } }
@Override public CompletionMatch complete() throws CompletionException { org.crsh.cli.spi.Completion.Builder builder = org.crsh.cli.spi.Completion.builder(prefix); for (CommandDescriptor<?> m : descriptor.getSubordinates().values()) { String name = m.getName(); if (name.startsWith(prefix)) { builder.add(name.substring(prefix.length()), true); } } return new CompletionMatch(delimiter, builder.build()); } }
@Override public CompletionMatch complete() throws CompletionException { org.crsh.cli.spi.Completion.Builder builder = org.crsh.cli.spi.Completion.builder(prefix); for (CommandDescriptor<?> m : descriptor.getSubordinates().values()) { String name = m.getName(); if (name.startsWith(prefix)) { if (!name.equals(mainName)) { builder.add(name.substring(prefix.length()), true); } } } return new CompletionMatch(delimiter, builder.build()); } }