(Arrays.asList(commandSpec.aliases()));
this.aliases.add(0, commandSpec.name());
- this.colorScheme = Assert.notNull(colorScheme, "colorScheme").applySystemProperties();
+ this.colorScheme = new ColorScheme.Builder(colorScheme).applySystemProperties().build();
parameterLabelRenderer = createDefaultParamLabelRenderer(); // uses help separator
this.addAllSubcommands(commandSpec.subcommands());
@@ -13004,40 +13004,29 @@ public Column(int width, int indent, Overflow overflow) {
* Users may customize these styles by creating Help with a custom color scheme.
* Note that these options and styles may not be rendered if ANSI escape codes are not
* {@linkplain Ansi#enabled() enabled}.
+ * From 4.0, instances of this class are immutable.
+ * @see Builder
* @see Help#defaultColorScheme(Ansi)
*/
public static class ColorScheme {
- public final List commandStyles = new ArrayList();
- public final List optionStyles = new ArrayList();
- public final List parameterStyles = new ArrayList();
- public final List optionParamStyles = new ArrayList();
+ private final List commandStyles;
+ private final List optionStyles;
+ private final List parameterStyles;
+ private final List optionParamStyles;
private final Ansi ansi;
- /** Constructs a new empty ColorScheme with {@link Help.Ansi#AUTO}. */
- public ColorScheme() { this(Ansi.AUTO); }
-
/** Constructs a new empty ColorScheme with the specified Ansi enabled mode.
* @see Help#defaultColorScheme(Ansi)
- * @param ansi whether to emit ANSI escape codes or not
+ * @param builder contains the color scheme attributes to use
*/
- public ColorScheme(Ansi ansi) {this.ansi = Assert.notNull(ansi, "ansi"); }
-
- /** Adds the specified styles to the registered styles for commands in this color scheme and returns this color scheme.
- * @param styles the styles to add to the registered styles for commands in this color scheme
- * @return this color scheme to enable method chaining for a more fluent API */
- public ColorScheme commands(IStyle... styles) { return addAll(commandStyles, styles); }
- /** Adds the specified styles to the registered styles for options in this color scheme and returns this color scheme.
- * @param styles the styles to add to registered the styles for options in this color scheme
- * @return this color scheme to enable method chaining for a more fluent API */
- public ColorScheme options(IStyle... styles) { return addAll(optionStyles, styles);}
- /** Adds the specified styles to the registered styles for positional parameters in this color scheme and returns this color scheme.
- * @param styles the styles to add to registered the styles for parameters in this color scheme
- * @return this color scheme to enable method chaining for a more fluent API */
- public ColorScheme parameters(IStyle... styles) { return addAll(parameterStyles, styles);}
- /** Adds the specified styles to the registered styles for option parameters in this color scheme and returns this color scheme.
- * @param styles the styles to add to the registered styles for option parameters in this color scheme
- * @return this color scheme to enable method chaining for a more fluent API */
- public ColorScheme optionParams(IStyle... styles) { return addAll(optionParamStyles, styles);}
+ ColorScheme(ColorScheme.Builder builder) {
+ Assert.notNull(builder, "builder");
+ this.ansi = Assert.notNull(builder.ansi(), "ansi");
+ commandStyles = Collections.unmodifiableList(new ArrayList(builder.commandStyles()));
+ optionStyles = Collections.unmodifiableList(new ArrayList(builder.optionStyles()));
+ parameterStyles = Collections.unmodifiableList(new ArrayList(builder.parameterStyles()));
+ optionParamStyles = Collections.unmodifiableList(new ArrayList(builder.optionParamStyles()));
+ }
/** Returns a Text with all command styles applied to the specified command string.
* @param command the command string to apply the registered command styles to
* @return a Text with all command styles applied to the specified command string */
@@ -13055,34 +13044,122 @@ public static class ColorScheme {
* @return a Text with all option parameter styles applied to the specified option parameter string */
public Ansi.Text optionParamText(String optionParam) { return ansi().apply(optionParam, optionParamStyles); }
- /** Replaces colors and styles in this scheme with ones specified in system properties, and returns this scheme.
- * Supported property names:
- * - {@code picocli.color.commands}
- * - {@code picocli.color.options}
- * - {@code picocli.color.parameters}
- * - {@code picocli.color.optionParams}
- *
Property values can be anything that {@link Help.Ansi.Style#parse(String)} can handle.
- * @return this ColorScheme
- */
- public ColorScheme applySystemProperties() {
- replace(commandStyles, System.getProperty("picocli.color.commands"));
- replace(optionStyles, System.getProperty("picocli.color.options"));
- replace(parameterStyles, System.getProperty("picocli.color.parameters"));
- replace(optionParamStyles, System.getProperty("picocli.color.optionParams"));
- return this;
- }
- private void replace(List styles, String property) {
- if (property != null) {
- styles.clear();
- addAll(styles, Style.parse(property));
- }
+ /** Returns the {@code Ansi} setting of this color scheme. */
+ public Ansi ansi() { return ansi; }
+ /** Returns the registered styles for commands in this color scheme.
+ * @since 4.0 */
+ public List commandStyles() { return commandStyles; }
+ /** Returns the registered styles for options in this color scheme.
+ * @since 4.0 */
+ public List optionStyles() { return optionStyles; }
+ /** Returns the registered styles for positional parameters in this color scheme.
+ * @since 4.0 */
+ public List parameterStyles() { return parameterStyles; }
+ /** Returns the registered styles for option parameters in this color scheme.
+ * @since 4.0 */
+ public List optionParamStyles() { return optionParamStyles; }
+
+ @Override public boolean equals(Object obj) {
+ if (this == obj) { return true; }
+ if (!(obj instanceof ColorScheme)) { return false; }
+ ColorScheme other = (ColorScheme) obj;
+ return ansi.equals(other.ansi)
+ && commandStyles.equals(other.commandStyles)
+ && optionStyles.equals(other.optionStyles)
+ && parameterStyles.equals(other.parameterStyles)
+ && optionParamStyles.equals(other.optionParamStyles);
}
- private ColorScheme addAll(List styles, IStyle... add) {
- styles.addAll(Arrays.asList(add));
- return this;
+ @Override public int hashCode() {
+ int result = 17;
+ result = result * 37 + ansi.hashCode();
+ result = result * 37 + commandStyles.hashCode();
+ result = result * 37 + optionStyles.hashCode();
+ result = result * 37 + parameterStyles.hashCode();
+ result = result * 37 + optionParamStyles.hashCode();
+ return result;
}
- public Ansi ansi() { return ansi; }
+ /** Builder class to create {@code ColorScheme} instances.
+ * @since 4.0 */
+ public static class Builder {
+ private final List commandStyles = new ArrayList();
+ private final List optionStyles = new ArrayList();
+ private final List parameterStyles = new ArrayList();
+ private final List optionParamStyles = new ArrayList();
+ private Ansi ansi = Ansi.AUTO;
+
+ /** Constructs an empty color scheme builder with Ansi.AUTO. */
+ public Builder() { }
+ /** Constructs an empty color scheme builder with the specified Ansi value. */
+ public Builder(Ansi ansi) { this.ansi = Assert.notNull(ansi, "ansi"); }
+ /** Constructs a color scheme builder with all attributes copied from the specified color scheme. */
+ public Builder(ColorScheme existing) {
+ Assert.notNull(existing, "colorScheme");
+ this.ansi = Assert.notNull(existing.ansi(), "ansi");
+ this.commandStyles.addAll(existing.commandStyles());
+ this.optionStyles.addAll(existing.optionStyles());
+ this.parameterStyles.addAll(existing.parameterStyles());
+ this.optionParamStyles.addAll(existing.optionParamStyles());
+ }
+ /** Returns the {@code Ansi} setting of this color scheme builder. */
+ public Ansi ansi() { return ansi; }
+ /** Returns the {@code Ansi} setting of this color scheme builder. */
+ public ColorScheme.Builder ansi(Ansi ansi) { this.ansi = Assert.notNull(ansi, "ansi"); return this; }
+ /** Returns the registered styles for commands in this color scheme builder. */
+ public List commandStyles() { return commandStyles; }
+ /** Returns the registered styles for options in this color scheme builder. */
+ public List optionStyles() { return optionStyles; }
+ /** Returns the registered styles for positional parameters in this color scheme builder. */
+ public List parameterStyles() { return parameterStyles; }
+ /** Returns the registered styles for option parameters in this color scheme builder. */
+ public List optionParamStyles() { return optionParamStyles; }
+
+ /** Adds the specified styles to the registered styles for commands in this color scheme builder and returns this builder.
+ * @param styles the styles to add to the registered styles for commands in this color scheme builder
+ * @return this color scheme builder to enable method chaining for a more fluent API */
+ public ColorScheme.Builder commands(IStyle... styles) { return addAll(commandStyles, styles); }
+ /** Adds the specified styles to the registered styles for options in this color scheme and returns this color scheme.
+ * @param styles the styles to add to registered the styles for options in this color scheme builder
+ * @return this color scheme builder to enable method chaining for a more fluent API */
+ public ColorScheme.Builder options(IStyle... styles) { return addAll(optionStyles, styles);}
+ /** Adds the specified styles to the registered styles for positional parameters in this color scheme builder and returns this builder.
+ * @param styles the styles to add to registered the styles for parameters in this color scheme builder
+ * @return this color scheme builder to enable method chaining for a more fluent API */
+ public ColorScheme.Builder parameters(IStyle... styles) { return addAll(parameterStyles, styles);}
+ /** Adds the specified styles to the registered styles for option parameters in this color scheme builder and returns this builder.
+ * @param styles the styles to add to the registered styles for option parameters in this color scheme builder
+ * @return this color scheme builder to enable method chaining for a more fluent API */
+ public ColorScheme.Builder optionParams(IStyle... styles) { return addAll(optionParamStyles, styles);}
+
+ /** Replaces colors and styles in this scheme builder with ones specified in system properties, and returns this builder.
+ * Supported property names:
+ * - {@code picocli.color.commands}
+ * - {@code picocli.color.options}
+ * - {@code picocli.color.parameters}
+ * - {@code picocli.color.optionParams}
+ *
Property values can be anything that {@link Help.Ansi.Style#parse(String)} can handle.
+ * @return this ColorScheme builder
+ */
+ public ColorScheme.Builder applySystemProperties() {
+ replace(commandStyles, System.getProperty("picocli.color.commands"));
+ replace(optionStyles, System.getProperty("picocli.color.options"));
+ replace(parameterStyles, System.getProperty("picocli.color.parameters"));
+ replace(optionParamStyles, System.getProperty("picocli.color.optionParams"));
+ return this;
+ }
+ private void replace(List styles, String property) {
+ if (property != null) {
+ styles.clear();
+ addAll(styles, Style.parse(property));
+ }
+ }
+ private ColorScheme.Builder addAll(List styles, IStyle... add) {
+ styles.addAll(Arrays.asList(add));
+ return this;
+ }
+ /** Creates and returns a new {@code ColorScheme} with the values configured on this builder. */
+ public ColorScheme build() { return new ColorScheme(this); }
+ }
}
/** Creates and returns a new {@link ColorScheme} initialized with picocli default values: commands are bold,
@@ -13091,11 +13168,11 @@ private ColorScheme addAll(List styles, IStyle... add) {
* @return a new default color scheme
*/
public static ColorScheme defaultColorScheme(Ansi ansi) {
- return new ColorScheme(ansi)
+ return new ColorScheme.Builder(ansi)
.commands(Style.bold)
.options(Style.fg_yellow)
.parameters(Style.fg_yellow)
- .optionParams(Style.italic);
+ .optionParams(Style.italic).build();
}
/** Provides methods and inner classes to support using ANSI escape codes in usage help messages. */
@@ -13313,6 +13390,15 @@ static class Palette256Color implements IStyle {
}
public String on() { return String.format(CSI + "%d;5;%dm", fgbg, color); }
public String off() { return CSI + (fgbg + 1) + "m"; }
+ public boolean equals(Object obj) {
+ if (obj == this) { return true; }
+ if (!(obj instanceof Palette256Color)) { return false; }
+ Palette256Color other = (Palette256Color) obj;
+ return other.fgbg == this.fgbg && other.color == this.color;
+ }
+ public int hashCode() {
+ return (17 + fgbg) * 37 + color;
+ }
}
private static class StyledSection {
int startIndex, length;
diff --git a/src/test/java/picocli/CommandLineHelpAnsiTest.java b/src/test/java/picocli/CommandLineHelpAnsiTest.java
index c56b9f213..866000d1b 100644
--- a/src/test/java/picocli/CommandLineHelpAnsiTest.java
+++ b/src/test/java/picocli/CommandLineHelpAnsiTest.java
@@ -165,11 +165,11 @@ public void testSystemPropertiesOverrideExplicitColorScheme() {
@CommandLine.Parameters(paramLabel = "FILE", arity = "1..*") File[] files;
}
Ansi ansi = Ansi.ON;
- CommandLine.Help.ColorScheme explicit = new CommandLine.Help.ColorScheme(ansi)
+ CommandLine.Help.ColorScheme explicit = new CommandLine.Help.ColorScheme.Builder(ansi)
.commands(Ansi.Style.faint, Ansi.Style.bg_magenta)
.options(Ansi.Style.bg_red)
.parameters(Ansi.Style.reverse)
- .optionParams(Ansi.Style.bg_green);
+ .optionParams(Ansi.Style.bg_green).build();
// default color scheme
assertEquals(ansi.new Text("@|faint,bg(magenta) |@ [@|bg(red) -v|@] [@|bg(red) -c|@=@|bg(green) |@] @|reverse FILE|@..." + LINESEP),
new CommandLine.Help(CommandLine.Model.CommandSpec.forAnnotatedObject(new App(), CommandLine.defaultFactory()), explicit).synopsis(0));
@@ -183,8 +183,8 @@ public void testSystemPropertiesOverrideExplicitColorScheme() {
}
@Test
public void testUsageWithCustomColorScheme() throws UnsupportedEncodingException {
- CommandLine.Help.ColorScheme scheme = new CommandLine.Help.ColorScheme(Ansi.ON)
- .options(Ansi.Style.bg_magenta).parameters(Ansi.Style.bg_cyan).optionParams(Ansi.Style.bg_yellow).commands(Ansi.Style.reverse);
+ CommandLine.Help.ColorScheme scheme = new CommandLine.Help.ColorScheme.Builder(Ansi.ON)
+ .options(Ansi.Style.bg_magenta).parameters(Ansi.Style.bg_cyan).optionParams(Ansi.Style.bg_yellow).commands(Ansi.Style.reverse).build();
class Args {
@CommandLine.Parameters(description = "param desc") String[] params;
@CommandLine.Option(names = "-x", description = "option desc") String[] options;
@@ -638,7 +638,7 @@ public void testStyleParseAllowsMissingClosingBrackets() {
@Test
public void testColorSchemeDefaultConstructorHasAnsiAuto() {
- CommandLine.Help.ColorScheme colorScheme = new CommandLine.Help.ColorScheme();
+ CommandLine.Help.ColorScheme colorScheme = new CommandLine.Help.ColorScheme.Builder().build();
assertEquals(Ansi.AUTO, colorScheme.ansi());
}
diff --git a/src/test/java/picocli/CommandLineHelpTest.java b/src/test/java/picocli/CommandLineHelpTest.java
index ecb7ae4f5..f33f101ed 100644
--- a/src/test/java/picocli/CommandLineHelpTest.java
+++ b/src/test/java/picocli/CommandLineHelpTest.java
@@ -2451,7 +2451,7 @@ public void testUsageNestedSubcommand() throws IOException {
@Test
public void testLayoutConstructorCreatesDefaultColumns() {
- ColorScheme colorScheme = new ColorScheme();
+ ColorScheme colorScheme = new ColorScheme.Builder().build();
Help.Layout layout = new Help.Layout(colorScheme, 99);
TextTable expected = TextTable.forDefaultColumns(Help.Ansi.OFF, 99);
@@ -2465,7 +2465,7 @@ public void testLayoutConstructorCreatesDefaultColumns() {
@Test
public void testHelpCreateLayout_CreatesDefaultColumns() {
- Help help = new Help(CommandSpec.create(), new ColorScheme(Help.Ansi.OFF));
+ Help help = new Help(CommandSpec.create(), new ColorScheme.Builder(Help.Ansi.OFF).build());
Help.Layout layout = help.createDefaultLayout();
TextTable expected = TextTable.forDefaultColumns(Help.Ansi.OFF, 80);
@@ -2487,7 +2487,7 @@ public void testMinimalParameterLabelRenderer() {
public void testMinimalOptionRenderer() {
Help.MinimalOptionRenderer renderer = new Help.MinimalOptionRenderer();
Text[][] texts = renderer.render(OptionSpec.builder("-x").build(),
- Help.createMinimalParamLabelRenderer(), new ColorScheme());
+ Help.createMinimalParamLabelRenderer(), new ColorScheme.Builder().build());
assertEquals("", texts[0][1].plainString());
}
@@ -2495,7 +2495,7 @@ public void testMinimalOptionRenderer() {
public void testMinimalParameterRenderer() {
Help.MinimalParameterRenderer renderer = new Help.MinimalParameterRenderer();
Text[][] texts = renderer.render(PositionalParamSpec.builder().build(),
- Help.createMinimalParamLabelRenderer(), new ColorScheme());
+ Help.createMinimalParamLabelRenderer(), new ColorScheme.Builder().build());
assertEquals("", texts[0][1].plainString());
}
@@ -2611,21 +2611,21 @@ public void trimTrailingLineSeparator() {
@Test
public void testHelpCreateDetailedSynopsisOptionsText() {
Help help = new Help(CommandSpec.create().addOption(OptionSpec.builder("xx").build()),
- new ColorScheme(Help.Ansi.OFF));
+ new ColorScheme.Builder(Help.Ansi.OFF).build());
Text text = help.createDetailedSynopsisOptionsText(new ArrayList(), null, true);
assertEquals(" [xx]", text.toString());
}
@Test
public void testAddAllSubcommands() {
- Help help = new Help(CommandSpec.create(), new Help.ColorScheme(Help.Ansi.OFF));
+ Help help = new Help(CommandSpec.create(), new ColorScheme.Builder(Help.Ansi.OFF).build());
help.addAllSubcommands(null);
assertTrue(help.subcommands().isEmpty());
}
@SuppressWarnings("deprecation")
@Test
public void testDetailedSynopsis() {
- Help help = new Help(CommandSpec.create(), new Help.ColorScheme(Help.Ansi.OFF));
+ Help help = new Help(CommandSpec.create(), new ColorScheme.Builder(Help.Ansi.OFF).build());
String str = help.detailedSynopsis(new Help.SortByShortestOptionNameAlphabetically(), true);
assertEquals(String.format("%n"), str);
}
@@ -2648,7 +2648,7 @@ public void testCreateDescriptionFirstLines() throws Exception {
};
for (int i = 0; i < input.length; i++) {
String[] description = input[i];
- Help.Ansi.Text[] result = (Help.Ansi.Text[]) m.invoke(null, new Help.ColorScheme(Help.Ansi.OFF), null, description, new boolean[3]);
+ Help.Ansi.Text[] result = (Help.Ansi.Text[]) m.invoke(null, new ColorScheme.Builder(Help.Ansi.OFF).build(), null, description, new boolean[3]);
Help.Ansi.Text[] expected = expectedOutput[i];
for (int j = 0; j < result.length; j++) {
@@ -2662,7 +2662,7 @@ public void testAbbreviatedSynopsis() {
CommandSpec spec = CommandSpec.create();
spec.addPositional(PositionalParamSpec.builder().paramLabel("a").hidden(true).build());
spec.addPositional(PositionalParamSpec.builder().paramLabel("b").build());
- Help help = new Help(spec, new Help.ColorScheme(Help.Ansi.OFF));
+ Help help = new Help(spec, new ColorScheme.Builder(Help.Ansi.OFF).build());
String actual = help.abbreviatedSynopsis();
assertEquals(String.format(" b...%n"), actual);
}
@@ -2670,7 +2670,7 @@ public void testAbbreviatedSynopsis() {
@SuppressWarnings("deprecation")
@Test
public void testSynopsis() {
- Help help = new Help(CommandSpec.create(), new Help.ColorScheme(Help.Ansi.OFF));
+ Help help = new Help(CommandSpec.create(), new ColorScheme.Builder(Help.Ansi.OFF).build());
String actual = help.synopsis();
assertEquals(String.format("%n"), actual);
}
@@ -2680,7 +2680,7 @@ public void testSynopsis() {
public void testAddSubcommand() {
@Command(name = "app", mixinStandardHelpOptions = true)
class App { }
- Help help = new Help(new CommandLine(CommandSpec.create()).getCommandSpec(), new Help.ColorScheme(Help.Ansi.OFF));
+ Help help = new Help(new CommandLine(CommandSpec.create()).getCommandSpec(), new ColorScheme.Builder(Help.Ansi.OFF).build());
help.addSubcommand("boo", new App());
assertEquals(1, help.subcommands().size());
assertEquals("app", help.subcommands().get("boo").commandSpec().name());
@@ -2972,11 +2972,11 @@ class App {
@SuppressWarnings("deprecation")
@Test
public void testPrintHelpIfRequestedWithCustomColorScheme() {
- ColorScheme customColorScheme = new Help.ColorScheme(Help.Ansi.ON)
+ ColorScheme customColorScheme = new ColorScheme.Builder(Help.Ansi.ON)
.optionParams(Style.fg_magenta)
.commands(Style.bg_cyan)
.options(Style.fg_green)
- .parameters(Style.bg_white);
+ .parameters(Style.bg_white).build();
@Command(mixinStandardHelpOptions = true)
class App {
diff --git a/src/test/java/picocli/HelpSubCommandTest.java b/src/test/java/picocli/HelpSubCommandTest.java
index 39f71e931..962bd921b 100644
--- a/src/test/java/picocli/HelpSubCommandTest.java
+++ b/src/test/java/picocli/HelpSubCommandTest.java
@@ -96,7 +96,10 @@ public void testCommandAliasAnnotationUsageHelp() {
CommandLine commandLine = new CommandLine(new TopLevelCommand());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- commandLine.usage(new PrintStream(baos), CommandLine.Help.defaultColorScheme(Help.Ansi.ON).commands(Help.Ansi.Style.underline)); // add underline
+ commandLine.usage(new PrintStream(baos),
+ new Help.ColorScheme.Builder(CommandLine.Help.defaultColorScheme(Help.Ansi.ON))
+ .commands(Help.Ansi.Style.underline)
+ .build()); // add underline
String expected = Help.Ansi.ON.new Text(String.format("" +
"Usage: @|bold,underline top|@ [COMMAND]%n" +
@@ -112,7 +115,10 @@ public void testCommandAliasAnnotationSubcommandUsageHelp() {
CommandLine commandLine = new CommandLine(new TopLevelCommand());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- commandLine.getSubcommands().get("sub").usage(new PrintStream(baos), CommandLine.Help.defaultColorScheme(Help.Ansi.ON).commands(Help.Ansi.Style.underline)); // add underline
+ commandLine.getSubcommands().get("sub").usage(new PrintStream(baos),
+ new CommandLine.Help.ColorScheme.Builder(CommandLine.Help.defaultColorScheme(Help.Ansi.ON))
+ .commands(Help.Ansi.Style.underline)
+ .build()); // add underline
String expected = Help.Ansi.ON.new Text(String.format("" +
"Usage: @|bold,underline top sub|@ [COMMAND]%n" +
diff --git a/src/test/java/picocli/SubcommandTests.java b/src/test/java/picocli/SubcommandTests.java
index 3793218ee..36fd74669 100644
--- a/src/test/java/picocli/SubcommandTests.java
+++ b/src/test/java/picocli/SubcommandTests.java
@@ -1082,10 +1082,11 @@ public void testColorScheme_AfterSubcommandsAdded() {
class TopLevel {}
CommandLine commandLine = new CommandLine(new TopLevel());
CommandLine.Help.ColorScheme original = commandLine.getColorScheme();
- assertEquals(Arrays.asList(CommandLine.Help.Ansi.Style.bold), original.commandStyles);
+ assertEquals(Arrays.asList(CommandLine.Help.Ansi.Style.bold), original.commandStyles());
- CommandLine.Help.ColorScheme scheme = new CommandLine.Help.ColorScheme();
- scheme.commands(CommandLine.Help.Ansi.Style.fg_black, CommandLine.Help.Ansi.Style.bg_cyan);
+ CommandLine.Help.ColorScheme scheme = new CommandLine.Help.ColorScheme.Builder()
+ .commands(CommandLine.Help.Ansi.Style.fg_black, CommandLine.Help.Ansi.Style.bg_cyan)
+ .build();
commandLine.setColorScheme(scheme);
assertEquals(scheme, commandLine.getColorScheme());
@@ -1111,10 +1112,11 @@ class TopLevel {}
CommandLine commandLine = new CommandLine(new TopLevel());
commandLine.addSubcommand("main", createNestedCommand());
CommandLine.Help.ColorScheme original = commandLine.getColorScheme();
- assertEquals(Arrays.asList(CommandLine.Help.Ansi.Style.bold), original.commandStyles);
+ assertEquals(Arrays.asList(CommandLine.Help.Ansi.Style.bold), original.commandStyles());
- CommandLine.Help.ColorScheme scheme = new CommandLine.Help.ColorScheme();
- scheme.commands(CommandLine.Help.Ansi.Style.fg_black, CommandLine.Help.Ansi.Style.bg_cyan);
+ CommandLine.Help.ColorScheme scheme = new CommandLine.Help.ColorScheme.Builder()
+ .commands(CommandLine.Help.Ansi.Style.fg_black, CommandLine.Help.Ansi.Style.bg_cyan)
+ .build();
commandLine.setColorScheme(scheme);
assertEquals(scheme, commandLine.getColorScheme());