Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 48769 invoked from network); 22 Jun 2006 21:28:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Jun 2006 21:28:01 -0000 Received: (qmail 12223 invoked by uid 500); 22 Jun 2006 21:27:58 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 12118 invoked by uid 500); 22 Jun 2006 21:27:58 -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 12104 invoked by uid 99); 22 Jun 2006 21:27:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jun 2006 14:27:57 -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; Thu, 22 Jun 2006 14:27:57 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 9B9F7410007 for ; Thu, 22 Jun 2006 21:26:30 +0000 (GMT) Message-ID: <7160706.1151011590634.JavaMail.jira@brutus> Date: Thu, 22 Jun 2006 21:26:30 +0000 (GMT+00:00) From: "Hairong Kuang (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Commented: (CLI-12) [cli] Not handling property=value followed by 'remaining' args 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-12?page=comments#action_12417373 ] Hairong Kuang commented on CLI-12: ---------------------------------- I came across the same problem. Here is how I would like to solve the problem. The problem here is that a programmer is not able to specify how an option's argments look like. In the example above, if we can specify that the -D option's arguments should contains a char "=", the parser knows to stop when it comes across an argument that does not contain "=". I'd like to add to the class Option an API setArgPattern(String argPattern, int limit), in which "argPattern" specifies the pattern that its argments should match and "limit" specifies exact times that the pattern can be applied. For the "-D" option, we should call setArgPattern( "=", 1). The idea is borrow from java String API, split( String regexp, int limit). > [cli] Not handling property=value followed by 'remaining' args > -------------------------------------------------------------- > > Key: CLI-12 > URL: http://issues.apache.org/jira/browse/CLI-12 > Project: Commons CLI > Type: Bug > Environment: Operating System: other > Platform: Other > Reporter: Jim Skufca > > If you have a command line args similar to > domything -Dmyprop1=myval1 -Dmyprop2=myval2 myfile > I would expect to be able to set up the 'D' option so that > String[] opts = line.getOptionValues( "D" ); > assertEquals( "myprop1", opts[0] ); > assertEquals( "myval1", opts[1] ); > assertEquals( "myprop2", opts[2] ); > assertEquals( "myval2", opts[3] ); > String[] xtraArgs = line.getArgs(); > assertEquals( "myfile", xtraArgs[0]); > But, setting up similar to the ApplicationTest.java I get 'myfile' as opts > [4]. Since we have set up the 'D' option with hasArgs, it will only stop > adding args to 'D' when it runs into another valid option, not an extra arg. > If you set up the 'D' option with hasArg (singular) then it myprop1=myval1 > gets reported as an invalid option. > I've glanced at the source but didn't see an obvious fix that wouldn't > jeopardize the combinations and permutations that Option.addValue() must deal > with. -- 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