Skip to content

Commit

Permalink
[grid] Allow cli commands to be hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jan 16, 2020
1 parent cc37627 commit d5cf59a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions java/server/src/org/openqa/selenium/cli/CliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public interface CliCommand {

Executable configure(String... args);

default boolean isShown() {
return true;
}

interface Executable {

void run() throws Exception;
Expand Down
5 changes: 4 additions & 1 deletion java/server/src/org/openqa/selenium/grid/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public String getDescription() {
public Executable configure(String... args) {
return () -> {
int longest = commands.stream()
.filter(CliCommand::isShown)
.map(CliCommand::getName)
.max(Comparator.comparingInt(String::length))
.map(String::length)
Expand All @@ -159,7 +160,9 @@ public Executable configure(String... args) {
String format = " %-" + longest + "s";

PrintWriter indented = new WrappedPrintWriter(System.out, 72, indent);
commands.forEach(cmd -> indented.format(format, cmd.getName())
commands.stream()
.filter(CliCommand::isShown)
.forEach(cmd -> indented.format(format, cmd.getName())
.append(cmd.getDescription())
.append("\n"));

Expand Down

0 comments on commit d5cf59a

Please sign in to comment.