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

* Re: Patch: even nicer help output
  2008-03-01 22:18 Patch: even nicer help output Tom Tromey
@ 2008-03-02 13:00 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2008-03-02 13:00 UTC (permalink / raw)
  To: tromey; +Cc: Frysk List

Hi Tom,

On Sat, 2008-03-01 at 14:27 -0700, Tom Tromey wrote:
> 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.

I agree, very nice.
For those following along at home, with this patch it looks as follows:

(fhpd) help print
print expression [-format d|o|x|t] -option ...; where options are:
  -format       print format
  -location     print the expression's location
  -raw          print the expression's raw value
  -tree         print the expression's AST
  -type         print the expression's type
  -value        print the expression's value (default)
The print command evaluates and displays an expression.  The debugger 
interprets the expression by looking up the value(s) associated with 
each symbol and applying the operators.  The result of an expression 
may be a scalar value or an aggregate (array, array slice, record, or 
structure.

> b/frysk-core/frysk/hpd/ChangeLog:
> 2008-03-01  Tom Tromey  <tromey@redhat.com>
> 
> 	* ParameterizedCommand.java (help): Align all option
> 	descriptions.

Committed and pushed (including your previous help improvement patches).

Thanks,

Mark

^ 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).