RAT-442: Update to commons-cli 1.11.0 and use new functionality of this release
https://github.com/apache/creadur-rat/pull/508 contais the plain dependabot update, but the new version brings:
- deprecations of HelpFormatter
- has to replace build() by get()
TODO
- [ ] fix test failures
- [ ] rework help display (add since as well)
- [ ] getParsedOptionValues from Arg
- [ ] do not use deprecated CLI methods anymore
To fix this PR the following actions should be taken.
Change from org.apache.commons.cli.HelpFormatter to org.apache.commons.cli.help.HelpFormatter
And then understand that the new help formatter is intended to be built just before use.
The AbstractHelp class
- get rid of
AbstractHelp.RatHelpFormatterclass. - should add a
HelpFormatter.Builderprotected final instance variable - the
HelpFormatter.Buildershould setShowSince totrue - the
HelpFormatter.Buildershould setComparator toOptionCollection.OPTION_COMPARATOR - he
HelpFormatter.Buildershould setOptionFormatBuilder to a instance of OptionFormatBuilder that has setDeprecatedFormatFunction set toDEPRECATED_MSG.
In the rat.Help class printUsage method
- A
TextAppendableshould be created that wraps the current writer. - The
TextAppendableshould have the max width set to the currentHELP_WIDTH - set the
HelpFormatter.Builder.setHelpAppendableto theTextAppendable; - call `HelpFormatter.Builder.get().printHelp(syntax, "", opts, "", true);
That will get us most of the way there for the basic help.
For the formatting of additional info use the TextHelpAppendable.printWrapped(), or create a table and use TextHelpAppendable.appendTable()
@Claudenw I also stumbled upon the rat.Licenses class, that showed me how much time I didn't spend in the sources ;)