You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@creadur.apache.org by "ottlinger (via GitHub)" <gi...@apache.org> on 2024/09/15 19:57:08 UTC
Re: [PR] RAT-384: write xsd (RAT-384 part 2) (Harmonize - Part 5) [creadur-rat]
ottlinger commented on code in PR #301:
URL: https://github.com/apache/creadur-rat/pull/301#discussion_r1760310804
##########
apache-rat-core/src/main/java/org/apache/rat/help/AbstractHelp.java:
##########
@@ -78,4 +80,98 @@ public static String createPadding(final int len) {
public static String header(final String txt) {
return String.format("%n====== %s ======%n", WordUtils.capitalizeFully(txt));
}
+
+ public class RatHelpFormatter extends HelpFormatter {
+
+ RatHelpFormatter() {
+ super();
+ this.optionComparator = OptionCollection.optionComparator;
+ this.setWidth(HELP_WIDTH);
+ }
+
+ public void printHelp(final PrintWriter pw, final String cmdLineSyntax, final String header, final Options options, final String footer) {
+ if (StringUtils.isEmpty(cmdLineSyntax)) {
+ throw new IllegalArgumentException("cmdLineSyntax not provided");
+ }
+
+ helpFormatter.printUsage(pw, HELP_WIDTH, cmdLineSyntax);
+
+ if (header != null && !header.isEmpty()) {
+ helpFormatter.printWrapped(pw, HELP_WIDTH, header);
+ }
+ printOptions(pw, HELP_WIDTH, options, helpFormatter.getLeftPadding(), helpFormatter.getDescPadding());
+ if (footer != null && !footer.isEmpty()) {
+ helpFormatter.printWrapped(pw, helpFormatter.getWidth(), footer);
+ }
+ }
+
+
+ protected StringBuffer renderOptions(final StringBuffer sb, final int width, final Options options, final int leftPad, final int descPad) {
Review Comment:
Isn't StringBuilder due to performance issues a better choice here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org