public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Patch: even nicer help output
@ 2008-03-01 22:18 Tom Tromey
  2008-03-02 13:00 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2008-03-01 22:18 UTC (permalink / raw)
  To: Frysk List

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-03-02 13:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-01 22:18 Patch: even nicer help output Tom Tromey
2008-03-02 13:00 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).