Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 30804 invoked from network); 7 Jun 2006 20:27:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Jun 2006 20:27:37 -0000 Received: (qmail 67474 invoked by uid 500); 7 Jun 2006 20:27:34 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 67397 invoked by uid 500); 7 Jun 2006 20:27:33 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 67386 invoked by uid 99); 7 Jun 2006 20:27:33 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2006 13:27:33 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2006 13:27:33 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C51FE7142C9 for ; Wed, 7 Jun 2006 20:26:30 +0000 (GMT) Message-ID: <181534.1149711990691.JavaMail.jira@brutus> Date: Wed, 7 Jun 2006 20:26:30 +0000 (GMT+00:00) From: "David DIDIER (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Commented: (CLI-15) [cli] HelpFormatter does not handle groups properly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/CLI-15?page=comments#action_12415201 ] David DIDIER commented on CLI-15: --------------------------------- It seems that it was not corrected. The code below: Option a = new Option("a", "aaa"); Option b = new Option("b", "bbb"); Option c = new Option("c", "ccc"); OptionGroup optionGroup = new OptionGroup(); optionGroup.addOption(a); optionGroup.addOption(b); Options options = new Options(); options.addOptionGroup(optionGroup); options.addOption(c); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("___", options, true); prints: usage: ___ [-b | -a][-c] [-a] -a aaa -b bbb -c ccc > [cli] HelpFormatter does not handle groups properly > --------------------------------------------------- > > Key: CLI-15 > URL: http://issues.apache.org/jira/browse/CLI-15 > Project: Commons CLI > Type: Bug > Versions: 1.0 Final > Environment: Operating System: All > Platform: All > Reporter: Etienne Pelletier > Attachments: HelpFormatter.java, Option.java > > The HelpFormatter repeats Options that have previously been printed with the group. > The problem is in the else block where options not belonging to a group are > printed. The code gets executed if it does not belong to a group -OR- if the > group has already been printed. > if( group != null && !list.contains(group)) { > // this gets executed when a new group is found > ... > } else { > // this gets executed if the group is OR ISN'T null, and if group is in list. > .... > } > The else statement on line 267 should be as follows: > } else if (group == null) { > // This will make sure that options that have not been printed as part of a group > // will not get printed again. > ... > } > I believe this change fixes the problem. > Also, the append on line 264 should add an extra space after the ] to make sure > that there will be a space between the ] and the next option. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org