From fc5ef6de6a4be43738155a81d01fdf4289a099db Mon Sep 17 00:00:00 2001 From: Remko Popma Date: Mon, 26 Oct 2020 20:46:05 +0900 Subject: [PATCH] [#1184] Added public method Help::calcLongOptionColumnWidth Closes #1184 --- RELEASE-NOTES.md | 2 +- src/main/java/picocli/CommandLine.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 6edb9e254..6622f2234 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -19,7 +19,7 @@ Picocli follows [semantic versioning](http://semver.org/). ## New and Noteworthy ## Fixed issues -* [#1184] API: Added public methods `Help.Layout::colorScheme`, `Help.Layout::textTable`, `Help.Layout::optionRenderer`, and `Help.Layout::parameterRenderer`. +* [#1184] API: Added public methods `Help.Layout::colorScheme`, `Help.Layout::textTable`, `Help.Layout::optionRenderer`, `Help.Layout::parameterRenderer`, and `Help::calcLongOptionColumnWidth`. * [#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. diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index c9d1bc839..15bcf9298 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -15090,7 +15090,13 @@ private Layout createLayout(int longOptionsColumnWidth, ColorScheme aColorScheme return new Layout(aColorScheme, tt, createDefaultOptionRenderer(), createDefaultParameterRenderer()); } - private int calcLongOptionColumnWidth(List options, List positionalParamSpecs, ColorScheme aColorScheme) { + /** Returns the width of the long options column in the usage help message. + * @param options the options shown in the usage help message + * @param positionals the positional parameters shown in the usage help message + * @param aColorScheme the colorscheme used in the layout to create {@linkplain Text} values + * @return the width of the long options column in the layout + * @since 4.6 */ + public int calcLongOptionColumnWidth(List options, List positionals, ColorScheme aColorScheme) { int max = 0; IOptionRenderer optionRenderer = new DefaultOptionRenderer(false, " "); boolean cjk = commandSpec.usageMessage().adjustLineBreaksForWideCJKCharacters();