This is the mail archive of the frysk@sourceware.org mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: even nicer help output


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();
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]