Skip to content

Commit

Permalink
[#1184] Added public methods to Help.Layout
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Oct 26, 2020
1 parent 02c735a commit f124ed7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Picocli follows [semantic versioning](http://semver.org/).
## <a name="4.6.0-new"></a> New and Noteworthy

## <a name="4.6.0-fixes"></a> Fixed issues
* [#1184] API: Added public methods `Help.Layout::colorScheme`, `Help.Layout::textTable`, `Help.Layout::optionRenderer`, and `Help.Layout::parameterRenderer`.
* [#1225] Bugfix: Error message for unmatched positional argument reports incorrect index when value equals a previously matched argument. Thanks to [Vitaly Shukela](https://github.com/vi) for raising this.
* [#1215] DOC: User manual improvements, including more tabs with Kotlin source code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1219] DOC: User manual improvements: added more tabs with Kotlin code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -15619,6 +15619,18 @@ public void addPositionalParameter(PositionalParamSpec param, IParamLabelRendere
}
/** Returns the section of the usage help message accumulated in the TextTable owned by this layout. */
@Override public String toString() { return table.toString(); }
/** Returns the ColorScheme used to create Text objects in this layout.
* @since 4.6 */
public ColorScheme colorScheme() { return colorScheme; }
/** Returns the TextTable used in this layout.
* @since 4.6 */
public TextTable textTable() { return table; }
/** Returns the IOptionRenderer used to render options to Text before adding this text to the TextTable in this layout.
* @since 4.6 */
public IOptionRenderer optionRenderer() { return optionRenderer; }
/** Returns the IParameterRenderer used to render positional params to Text before adding this text to the TextTable in this layout.
* @since 4.6 */
public IParameterRenderer parameterRenderer() { return parameterRenderer; }
}
/** Sorts short strings before longer strings. */
static class ShortestFirst implements Comparator<String> {
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/picocli/HelpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,25 @@ public void testUsageNestedSubcommand() throws IOException {
" sub22sub1%n"), sub22);
}

@Test
public void testLayoutGetters() {
ColorScheme colorScheme = new ColorScheme.Builder().build();
TextTable table = TextTable.forDefaultColumns(colorScheme, 20, 80);
Help.IOptionRenderer optionRenderer = Help.createMinimalOptionRenderer();
Help.IParameterRenderer paramRenderer = Help.createMinimalParameterRenderer();
Help.Layout layout = new Help.Layout(colorScheme, table, optionRenderer, paramRenderer);

assertSame(colorScheme, layout.colorScheme());
assertSame(table, layout.textTable());
assertSame(optionRenderer, layout.optionRenderer());
assertSame(paramRenderer, layout.parameterRenderer());

assertSame(layout.colorScheme, layout.colorScheme());
assertSame(layout.table, layout.textTable());
assertSame(layout.optionRenderer, layout.optionRenderer());
assertSame(layout.parameterRenderer, layout.parameterRenderer());
}

@SuppressWarnings("deprecation")
@Test
public void testLayoutConstructorCreatesDefaultColumns() {
Expand Down

0 comments on commit f124ed7

Please sign in to comment.