/** * Looks up a Server launcher command by name. The equality comparison on name is * case-insensitive. * * @param name a String value indicating the name of the Server launcher command. * @return an enumerated type representing the command name or null if the no such command with * the specified name exists. */ public static Command valueOfName(final String name) { for (final Command command : values()) { if (command.getName().equalsIgnoreCase(name)) { return command; } } return null; }
commandLine.add(ServerLauncher.Command.START.getName());
/** * Displays help for the specified Server launcher command to standard err. If the Server launcher * command is unspecified, then usage information is displayed instead. * * @param command the Server launcher command in which to display help information. * @see #usage() */ public void help(final Command command) { if (Command.isUnspecified(command)) { usage(); } else { info(wrap(helpMap.get(command.getName()), 80, "")); info("\n\nusage: \n\n"); info(wrap("> java ... " + getClass().getName() + ' ' + usageMap.get(command), 80, "\t\t")); info("\n\noptions: \n\n"); for (final String option : command.getOptions()) { info(wrap("--" + option + ": " + helpMap.get(option) + '\n', 80, "\t")); } info("\n\n"); } }
expectedCommandLineElements.add(serverLauncher.getCommand().getName()); expectedCommandLineElements.add("--disable-default-server"); expectedCommandLineElements.add(serverLauncher.getMemberName().toLowerCase());
expectedCommandLineElements.add(serverLauncher.getCommand().getName()); expectedCommandLineElements.add("--disable-default-server"); expectedCommandLineElements.add(serverLauncher.getMemberName().toLowerCase());
@Test public void parseCommandWithStartResultsInStartCommand() { Builder builder = new Builder(); builder.parseCommand(Command.START.getName()); assertThat(builder.getCommand()).isEqualTo(Command.START); }
@Test public void parseCommandWithTwoCommandsWithoutSwitchesUsesFirstCommand() { Builder builder = new Builder(); builder.parseCommand("START", Command.STATUS.getName()); assertThat(builder.getCommand()).isEqualTo(Command.START); }
/** * Gets the String representation of this Server launcher command. * * @return a String value representing this Server launcher command. */ @Override public String toString() { return getName(); } }
@Test public void parseMemberNameWithCommandAndOptionsResultsInNull() { Builder builder = new Builder(); builder.parseMemberName(Command.START.getName(), "--opt", "-o"); assertThat(builder.getMemberName()).isNull(); }
@Test public void parseCommandWithTwoCommandsWithSwitchesUsesFirstCommand() { Builder builder = new Builder(); builder.parseCommand("--opt", "START", "-o", Command.STATUS.getName()); assertThat(builder.getCommand()).isEqualTo(Command.START); }