Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Oct 15, 2015
1 parent 392c8bb commit 606cd04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
7 changes: 4 additions & 3 deletions java/server/src/org/openqa/grid/selenium/GridLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openqa.selenium.remote.server.log.TerseFormatter;
import org.openqa.selenium.server.SeleniumServer;
import org.openqa.selenium.server.cli.RemoteControlLauncher;
import org.openqa.selenium.server.shared.CliUtils;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -98,11 +99,11 @@ public static void main(String[] args) throws Exception {

private static void printInfoAboutRoles(CommandLineOptionHelper helper) {
if (helper.hasParamValue("-role")) {
RemoteControlLauncher.printWrappedLine(
CliUtils.printWrappedLine(
"",
"Error: the role '" + helper.getParamValue("-role") + "' does not match a recognized server role\n");
} else {
RemoteControlLauncher.printWrappedLine(
CliUtils.printWrappedLine(
"",
"Error: -role option needs to be followed by the value that defines role of this component in the grid\n");
}
Expand All @@ -113,7 +114,7 @@ private static void printInfoAboutRoles(CommandLineOptionHelper helper) {
" standalone as a standalone server not being a part of a grid\n" +
"\n" +
"If -role option is omitted the server runs standalone\n");
RemoteControlLauncher.printWrappedLine(
CliUtils.printWrappedLine(
"",
"To get help on the options available for a specific role run the server"
+ " with -help option and the corresponding -role option value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.openqa.selenium.server.cli;

import static org.openqa.selenium.server.shared.CliUtils.printWrappedLine;

import org.openqa.selenium.server.InjectionHelper;
import org.openqa.selenium.server.RemoteControlConfiguration;

Expand Down Expand Up @@ -294,31 +296,6 @@ public static String getArg(String[] args, int i) {
return args[i];
}

public static void printWrappedLine(String prefix, String msg) {
printWrappedLine(System.out, prefix, msg, true);
}

public static void printWrappedLine(PrintStream output, String prefix, String msg, boolean first) {
output.print(prefix);
if (!first) {
output.print(" ");
}
int defaultWrap = 70;
int wrap = defaultWrap - prefix.length();
if (wrap > msg.length()) {
output.println(msg);
return;
}
String lineRaw = msg.substring(0, wrap);
int spaceIndex = lineRaw.lastIndexOf(' ');
if (spaceIndex == -1) {
spaceIndex = lineRaw.length();
}
String line = lineRaw.substring(0, spaceIndex);
output.println(line);
printWrappedLine(output, prefix, msg.substring(spaceIndex + 1), false);
}

public static void setSystemProperty(String arg) {
if (arg.indexOf('=') == -1) {
usage("poorly formatted Java property setting (I expect to see '=') " + arg);
Expand Down

0 comments on commit 606cd04

Please sign in to comment.