Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 84884 invoked from network); 22 Apr 2003 19:48:08 -0000 Received: from mail2.cargill.com (HELO mgocdc02.cargill.com) (167.136.25.148) by daedalus.apache.org with SMTP; 22 Apr 2003 19:48:08 -0000 Received: from mgocdc02.cargill.com (localhost [127.0.0.1]) by mgocdc02.cargill.com (Relay) with ESMTP� id h3MJlqr25172 for ; Tue, 22 Apr 2003 14:47:52 -0500 (CDT) Received: from hdqt.cargill.com (hdqt.cargill.com [10.2.105.11]) by mgocdc02.cargill.com with ESMTP id h3MJjd522513 for ; Tue, 22 Apr 2003 14:47:29 -0500 (CDT) Received: from localhost (root@localhost) by hdqt.cargill.com (8.9.3 (PHNE_25184)/8.8.6) with ESMTP id OAA04165 for ; Tue, 22 Apr 2003 14:45:37 -0500 (CDT) X-OpenMail-Hops: 1 Date: Tue, 22 Apr 2003 14:45:35 -0500 Message-Id: Subject: unexpected parsing behavior MIME-Version: 1.0 From: Darin_Hawley@cargill.com TO: commons-user@jakarta.apache.org Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline; filename="BDY.TXT" ;Creation-Date="Tue, 22 Apr 2003 14:45:35 -0500" Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Based on the Usage Scenarios (http://jakarta.apache.org/commons/cli/usage.html), (in particular the ant example), I was expecting to specify options with long names like 'buildfile'. The behavior I'm seeing would suggest that option names must be a single character. I wrote a simple test program below and got the following unexpected results. If nothing else, it would seem that the HelpFormatter presents an inconsistent picture of what the parser expects. Could someone please clarify and/or update the Usage Scenarios? Thanks. ---- java CliTest -test hello org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -t at org.apache.commons.cli.Parser.processOption(Parser.java:253) at org.apache.commons.cli.Parser.parse(Parser.java:170) at org.apache.commons.cli.Parser.parse(Parser.java:114) at CliTest.main(CliTest.java:18) usage: command [options] -test a test value ---- import org.apache.commons.cli.*; public class CliTest { public static void main(String[] args) throws Exception { Option testOption = OptionBuilder.withArgName("testValue") .hasArg().withDescription("a test value") .create("test"); Options options = new Options(); options.addOption(testOption); try { CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(options,args); } catch (Exception e) { e.printStackTrace(); new HelpFormatter().printHelp("command [options]", options); } } }