From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10159 invoked by alias); 1 Mar 2008 22:18:27 -0000 Received: (qmail 10152 invoked by uid 22791); 1 Mar 2008 22:18:27 -0000 X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 01 Mar 2008 22:18:09 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m21MI8lq003876 for ; Sat, 1 Mar 2008 17:18:08 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m21MI7KJ025651 for ; Sat, 1 Mar 2008 17:18:08 -0500 Received: from opsy.redhat.com (vpn-14-173.rdu.redhat.com [10.11.14.173]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m21MI799030799; Sat, 1 Mar 2008 17:18:07 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id C49D63780C7; Sat, 1 Mar 2008 14:27:52 -0700 (MST) To: Frysk List Subject: Patch: even nicer help output From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom Date: Sat, 01 Mar 2008 22:18:00 -0000 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.990 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2008-q1/txt/msg00099.txt.bz2 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 * 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(); }