This is the mail archive of the
frysk@sourceware.org
mailing list for the frysk project.
Patch: even nicer help output
- From: Tom Tromey <tromey at redhat dot com>
- To: Frysk List <frysk at sourceware dot org>
- Date: Sat, 01 Mar 2008 14:27:52 -0700
- Subject: Patch: even nicer help output
- Reply-to: tromey at redhat dot com
This patch should be applied after the earlier word-wrap patch.
This one lines up all the descriptions of the options when printing
help for a command. This looks a lot nicer to me.
Tom
b/frysk-core/frysk/hpd/ChangeLog:
2008-03-01 Tom Tromey <tromey@redhat.com>
* ParameterizedCommand.java (help): Align all option
descriptions.
diff --git a/frysk-core/frysk/hpd/ParameterizedCommand.java b/frysk-core/frysk/hpd/ParameterizedCommand.java
index 99bfe7c..d13a4ec 100644
--- a/frysk-core/frysk/hpd/ParameterizedCommand.java
+++ b/frysk-core/frysk/hpd/ParameterizedCommand.java
@@ -152,17 +152,26 @@ abstract class ParameterizedCommand extends Command {
out.print(syntax);
if (longOptions.size() > 0) {
out.println(" -option ...; where options are:");
+ int maxLen = 0;
+ for (Iterator i = longOptions.values().iterator();
+ i.hasNext(); ) {
+ CommandOption option = (CommandOption)i.next();
+ maxLen = Math.max(maxLen, option.longName.length());
+ }
+ // 3 for the " -", 5 for the gap.
+ maxLen += 3 + 5;
+ out.setWrapIndent(maxLen);
for (Iterator i = longOptions.values().iterator();
i.hasNext(); ) {
CommandOption option = (CommandOption)i.next();
out.print(" -");
out.print(option.longName);
- out.print("\t");
- out.setWrapIndentFromColumn();
+ for (int j = 3 + option.longName.length(); j < maxLen; ++j)
+ out.print(" ");
out.print(option.description);
- out.setWrapIndent(0);
out.println();
}
+ out.setWrapIndent(0);
} else {
out.println();
}