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 00EC6EC60 for ; Sat, 9 Feb 2013 14:33:15 +0000 (UTC) Received: (qmail 18627 invoked by uid 500); 9 Feb 2013 14:33:14 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 18550 invoked by uid 500); 9 Feb 2013 14:33:13 -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 18506 invoked by uid 99); 9 Feb 2013 14:33:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Feb 2013 14:33:12 +0000 Date: Sat, 9 Feb 2013 14:33:12 +0000 (UTC) From: "Thomas Neidhart (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (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 [ https://issues.apache.org/jira/browse/CLI-221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13575176#comment-13575176 ] Thomas Neidhart commented on CLI-221: ------------------------------------- I do not see this as a bug. The withValueSeparator option does not mean that the arguments *must* be concatenated by this separator. It currently works only as an optional splitting mechanism. Any (whitespace) separated tokens after the option will be treated as its arguments. > 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: Parser > Affects Versions: 1.2 > Reporter: Gagan Jain > > 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 > {code}cmd1 -o1 o1v1,o1v2,o1v3 a1v1{code} > 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. > {code:java} > 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); > } > } > {code} > 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. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira