@Override public void print(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append(command.getUsage()); } }
public void printNameSection(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append("NAME\n"); stream.append(Util.MAN_TAB); printFQN(command, stream); String usage = command.getUsage(); if (usage.length() > 0) { stream.append(" - ").append(usage); } stream.append("\n\n"); }
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"); } }
public void testCommandDescription() throws IntrospectionException { class A { } CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class); assertEquals("", c.getUsage()); assertEquals(0, c.getArguments().size()); assertEquals(0, c.getOptions().size()); }
public void testCommandImplicitDescription() throws IntrospectionException { class A { } CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class); assertEquals("", c.getUsage()); assertEquals(0, c.getArguments().size()); assertEquals(0, c.getOptions().size()); }
public void testNoDescription() throws Exception { class A { } CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class); assertEquals("", c.getUsage()); assertEquals(new Description(), c.getDescription()); }
@Override public void print(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append(command.getUsage()); } }
public void testClassDescription() throws Exception { @Usage("class_usage") @Man("class_man") class A { } CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class); assertEquals("class_usage", c.getUsage()); assertEquals("class_usage", c.getDescription().getUsage()); assertEquals("class_man", c.getDescription().getMan()); }
public void testMethodDescription() throws Exception { class A { @Usage("method_usage") @Man("method_man") @Command void m() {} } CommandDescriptor<Instance<A>> c = CommandFactory.DEFAULT.create(A.class); CommandDescriptor<Instance<A>> m = c.getSubordinate("m"); assertEquals("method_usage", m.getUsage()); assertEquals("method_usage", m.getDescription().getUsage()); assertEquals("method_man", m.getDescription().getMan()); }
public void printNameSection(CommandDescriptor<?> command, Appendable stream) throws IOException { stream.append("NAME\n"); stream.append(Util.MAN_TAB); printFQN(command, stream); String usage = command.getUsage(); if (usage.length() > 0) { stream.append(" - ").append(usage); } stream.append("\n\n"); }
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"); } }
for (CommandDescriptor<T> method : methods.values()) { Formatter formatter = new Formatter(writer); formatter.format(format, method.getName(), method.getUsage());
switch (mode) { case DESCRIBE: return match.getDescriptor().getUsage(); case MAN: StringWriter sw = new StringWriter();