public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Frysk List <frysk@sourceware.org>
Subject: Patch: even nicer help output
Date: Sat, 01 Mar 2008 22:18:00 -0000	[thread overview]
Message-ID: <m3mypif82v.fsf@fleche.redhat.com> (raw)

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

             reply	other threads:[~2008-03-01 22:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-01 22:18 Tom Tromey [this message]
2008-03-02 13:00 ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3mypif82v.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).