List of usage examples for java.lang Class name
String name
To view the source code for java.lang Class name.
Click Source Link
From source file:org.eclim.command.Main.java
public static void usage(String cmd, PrintStream out) { ArrayList<org.eclim.annotation.Command> commands = new ArrayList<org.eclim.annotation.Command>(); for (Class<? extends Command> command : Services.getCommandClasses()) { commands.add(command.getAnnotation(org.eclim.annotation.Command.class)); }/*from w w w.ja v a2s .co m*/ Collections.sort(commands, new Comparator<org.eclim.annotation.Command>() { public int compare(org.eclim.annotation.Command o1, org.eclim.annotation.Command o2) { return o1.name().compareTo(o2.name()); } }); boolean cmdFound = cmd == null; if (cmd == null) { String osOpts = StringUtils.EMPTY; if (SystemUtils.IS_OS_UNIX) { osOpts = " [-f eclimrc] [--nailgun-port port]"; } out.println("Usage: eclim" + osOpts + " -command command [args]"); out.println(" To view a full list of available commands:"); out.println(" eclim -? commands"); out.println(" To view info for a specific command:"); out.println(" eclim -? <command_name>"); out.println(" Ex."); out.println(" eclim -? project_create"); } else if (cmd.equals("commands")) { out.println("Available Commands:"); } else { out.println("Requested Command:"); } for (org.eclim.annotation.Command command : commands) { if (cmd == null || (!cmd.equals(command.name()) && !cmd.equals("commands"))) { continue; } cmdFound = true; Collection<Option> options = new Options().parseOptions(command.options()); StringBuffer opts = new StringBuffer(); Iterator<Option> iterator = options.iterator(); for (int ii = 0; iterator.hasNext(); ii++) { Option option = iterator.next(); opts.append(option.isRequired() ? " " : " ["); opts.append('-').append(option.getOpt()); if (option.hasArg()) { opts.append(' ').append(option.getLongOpt()); } if (!option.isRequired()) { opts.append(']'); } // wrap every 4 options if ((ii + 1) % 4 == 0 && ii != options.size() - 1) { opts.append(StringUtils.rightPad("\n", command.name().length() + 5)); } } StringBuffer info = new StringBuffer().append(" ").append(command.name()).append(opts); out.println(info); if (!command.description().equals(StringUtils.EMPTY)) { out.println(" " + command.description()); } } if (!cmdFound) { out.println(" No Such Command: " + cmd); } }