Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 77A427179 for ; Tue, 6 Sep 2011 11:45:41 +0000 (UTC) Received: (qmail 60983 invoked by uid 500); 6 Sep 2011 11:45:40 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 60803 invoked by uid 500); 6 Sep 2011 11:45:35 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 60328 invoked by uid 99); 6 Sep 2011 11:45:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2011 11:45:33 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2011 11:45:30 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id CB12D83838 for ; Tue, 6 Sep 2011 11:45:09 +0000 (UTC) Date: Tue, 6 Sep 2011 11:45:09 +0000 (UTC) From: "Gagan Jain (JIRA)" To: issues@commons.apache.org Message-ID: <1394743129.20074.1315309509828.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2072097522.19932.1315307170229.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (CLI-221) cli's with last option as list type values and have argument are not parsed correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CLI-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Gagan Jain updated CLI-221: --------------------------- Component/s: CLI-2.x > cli's with last option as list type values and have argument are not parsed correctly > ------------------------------------------------------------------------------------- > > Key: CLI-221 > URL: https://issues.apache.org/jira/browse/CLI-221 > Project: Commons CLI > Issue Type: Bug > Components: CLI-2.x, Parser > Affects Versions: 1.2 > Reporter: Gagan Jain > Labels: bug, cli2, list, parser > > I have set the value separator for an option to be comma (','). > Consider the following cli: > cli definition : cmd1 -o1 a1 > command name: 'cmd1' > options: 'o1' accpets list of values separated by ',' > arguments: 'a1' single valued argument > cmd1 -o1 o1v1,o1v2,o1v3 a1v1 > GnuParser parses this the cli with o1 having values {o1v1, o1v2, o1v3, a1v1} instead of {o1v1,o1v2,o1v3} > Bug seems to be in org.apache.commons.cli.Parser's class processArgs method. > public void processArgs(Option opt, ListIterator iter) throws ParseException > { > // loop until an option is found > while (iter.hasNext()) > { > String str = (String) iter.next(); > // found an Option, not an argument > if (getOptions().hasOption(str) && str.startsWith("-")) > { > iter.previous(); > break; > } > // found a value > try > { > opt.addValueForProcessing(Util.stripLeadingAndTrailingQuotes(str)); > } > catch (RuntimeException exp) > { > iter.previous(); > break; > } > } > if (opt.getValues() == null && !opt.hasOptionalArg()) > { > throw new MissingArgumentException(opt); > } > } > In my opinion, if a value separator is defined for option, and is other than space (' '), loop should break immediately after one iteration. > Correct me, if I am wrong in my understanding. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira