svn commit: r384201 - /jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/tar/TarBuffer.java
Author: roxspring Date: Wed Mar 8 04:38:21 2006 New Revision: 384201 URL: http://svn.apache.org/viewcvs?rev=384201view=rev Log: Applied Ant fix: http://svn.apache.org/viewcvs.cgi/ant/core/trunk/src/main/org/apache/tools/tar/TarBuffer.java?rev=277329r1=276208r2=277329 For bug: http://issues.apache.org/bugzilla/show_bug.cgi?id=29877 Modified: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/tar/TarBuffer.java Modified: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/tar/TarBuffer.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/tar/TarBuffer.java?rev=384201r1=384200r2=384201view=diff == --- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/tar/TarBuffer.java (original) +++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/tar/TarBuffer.java Wed Mar 8 04:38:21 2006 @@ -1,5 +1,5 @@ /* - * Copyright 2002,2004 The Apache Software Foundation. + * Copyright 2002,2004,2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Arrays; /** * The TarBuffer class implements the tar archive concept of a buffered input @@ -438,6 +439,14 @@ // if( numBytes == -1 ) { +// However, just leaving the unread portion of the buffer dirty does +// cause problems in some cases. This problem is described in +// http://issues.apache.org/bugzilla/show_bug.cgi?id=29877 +// +// The solution is to fill the unused portion of the buffer with zeros. + +Arrays.fill(m_blockBuffer, offset, offset + bytesNeeded, (byte) 0); + break; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r209506 - /jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt
Author: roxspring Date: Wed Jul 6 12:41:55 2005 New Revision: 209506 URL: http://svn.apache.org/viewcvs?rev=209506view=rev Log: Merged r129840 to branch Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt?rev=209506r1=209505r2=209506view=diff == --- jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt (original) +++ jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt Wed Jul 6 12:41:55 2005 @@ -1,4 +1,4 @@ -$Id: RELEASE-NOTES.txt,v 1.1 2002/11/06 05:09:21 bayard Exp $ +$Id$ Commons CLI Package Version 1.0 @@ -8,7 +8,7 @@ INTRODUCTION: This document contains the release notes for this version of the Commons -CLI package. Commons CLI provdes a simple API for working with the command line arguments and options. +CLI package. Commons CLI provides a simple API for working with the command line arguments and options. This is the first release of the CLI component, therefore all features are new, there are no bug-fixes, nothing is deprecated and there are no changes. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r209508 - in /jakarta/commons/proper/cli/branches/CLI_1_BRANCH: src/java/org/apache/commons/cli/ src/test/org/apache/commons/cli/ xdocs/
Author: roxspring Date: Wed Jul 6 13:03:54 2005 New Revision: 209508 URL: http://svn.apache.org/viewcvs?rev=209508view=rev Log: Merged 129840:129847 to the branch Added: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/OptionValidator.java - copied unchanged from r129847, jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/OptionValidator.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/Util.java - copied unchanged from r129847, jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/Util.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/test/org/apache/commons/cli/OptionsTest.java - copied unchanged from r129847, jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli/OptionsTest.java Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/CommandLine.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/CommandLineParser.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/HelpFormatter.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/Option.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/OptionBuilder.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/OptionGroup.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/Options.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/Parser.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/test/org/apache/commons/cli/BugsTest.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/test/org/apache/commons/cli/OptionBuilderTest.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/test/org/apache/commons/cli/OptionGroupTest.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/test/org/apache/commons/cli/ParseTest.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/test/org/apache/commons/cli/ValueTest.java jakarta/commons/proper/cli/branches/CLI_1_BRANCH/xdocs/introduction.xml jakarta/commons/proper/cli/branches/CLI_1_BRANCH/xdocs/usage.xml Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/CommandLine.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/CommandLine.java?rev=209508r1=209507r2=209508view=diff == --- jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/CommandLine.java (original) +++ jakarta/commons/proper/cli/branches/CLI_1_BRANCH/src/java/org/apache/commons/cli/CommandLine.java Wed Jul 6 13:03:54 2005 @@ -91,6 +91,9 @@ /** the processed options */ private Map options = new HashMap(); +/** the option name map */ +private Map names = new HashMap(); + /** Map of unique options for ease to get complete list of options */ private Map hashcodeMap = new HashMap(); @@ -132,7 +135,7 @@ public Object getOptionObject( String opt ) { String res = getOptionValue( opt ); -Object type = ((Option)((List)options.get(opt)).iterator().next()).getType(); +Object type = ((Option)options.get(opt)).getType(); return res == null ? null : TypeHandler.createValue(res, type); } @@ -179,16 +182,17 @@ public String[] getOptionValues( String opt ) { List values = new java.util.ArrayList(); -if( options.containsKey( opt ) ) { -List opts = (List)options.get( opt ); -Iterator iter = opts.iterator(); - -while( iter.hasNext() ) { -Option optt = (Option)iter.next(); -values.addAll( optt.getValuesList() ); -} +opt = Util.stripLeadingHyphens( opt ); + +String key = opt; +if( names.containsKey( opt ) ) { +key = (String)names.get( opt ); +} + +if( options.containsKey( key ) ) { +return ((Option)options.get(key)).getValues(); } -return (values.size() == 0) ? null : (String[])values.toArray(new String[]{}); +return null; } /** @@ -286,18 +290,15 @@ void addOption( Option opt ) { hashcodeMap.put( new Integer( opt.hashCode() ), opt ); -String key = opt.getOpt(); -if( .equals(key) ) { +String key = opt.getKey(); +if( key == null ) { key = opt.getLongOpt(); } - -if( options.get( key ) != null ) { -((java.util.List)options.get( key )).add( opt ); -} else { -options.put( key, new java.util.ArrayList() ); -((java.util.List)options.get( key
svn commit: r209528 - /jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt
Author: roxspring Date: Wed Jul 6 15:23:49 2005 New Revision: 209528 URL: http://svn.apache.org/viewcvs?rev=209528view=rev Log: Updated release notes inline with the merged commits Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt?rev=209528r1=209527r2=209528view=diff == --- jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt (original) +++ jakarta/commons/proper/cli/branches/CLI_1_BRANCH/RELEASE-NOTES.txt Wed Jul 6 15:23:49 2005 @@ -1,8 +1,8 @@ $Id$ - Commons CLI Package - Version 1.0 - Release Notes + Commons CLI Package + Version 1.1 + Release Notes INTRODUCTION: @@ -18,9 +18,49 @@ NEW FEATURES: +* Support for boolean/flag options from properties + BUG FIXES: +#35191 - Documentation enhancement + Submitted by: Liu yehui + +#32525 - Parser breaks up command line parms into single characters + Submitted by: David Morris + +#31148 - Passing properties in Parser does not work for options with a single argument + +#30371 - readme lists deprecate maven goal and old maven URL + Submitted by: Brant Langer Gurganus + +#30089 - Documentation fixes + Submitted by: Dennis Lundberg + +#27635 - Only long options without short option seems to be noticed + +#25044 - Error parsing option arguments + Submitted by: David Morris + +#21215 - Line separator as first char for helpformatter (footer) throws exception + +#19383 - Missing arguments in HelpFormatter.renderOptions(..) + +#15648 - Quoted strings as a single argument. + +#15046 - MissingArgumentException: no argument for option is thrown when the option's parameter equals to an existing option. + +#14786 - Options should not be able to be added more than once + DEPRECATIONS: CHANGES: +* Updated to Apache License 2.0 and included NOTICE file in distributions + +* Updated introduction documentation + +* Improved javadocs + +* More tests + +* Improved help formatter - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r209529 - in /jakarta/commons/proper/cli/branches/CLI_1_BRANCH: maven.xml project.xml
Author: roxspring Date: Wed Jul 6 15:25:19 2005 New Revision: 209529 URL: http://svn.apache.org/viewcvs?rev=209529view=rev Log: Preparing for a 1.1 release. RELEASE-NOTES.txt now included in distributions Added me as developer Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/maven.xml jakarta/commons/proper/cli/branches/CLI_1_BRANCH/project.xml Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/maven.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/branches/CLI_1_BRANCH/maven.xml?rev=209529r1=209528r2=209529view=diff == --- jakarta/commons/proper/cli/branches/CLI_1_BRANCH/maven.xml (original) +++ jakarta/commons/proper/cli/branches/CLI_1_BRANCH/maven.xml Wed Jul 6 15:25:19 2005 @@ -39,6 +39,7 @@ postGoal name=dist:prepare-src-filesystem copy todir=${maven.dist.src.assembly.dir} fileset file=${basedir}/NOTICE.txt/ + fileset file=${basedir}/RELEASE-NOTES.txt/ /copy /postGoal @@ -46,6 +47,7 @@ preGoal name=dist:build-bin copy todir=${maven.dist.bin.assembly.dir} fileset file=${basedir}/NOTICE.txt/ + fileset file=${basedir}/RELEASE-NOTES.txt/ /copy /preGoal Modified: jakarta/commons/proper/cli/branches/CLI_1_BRANCH/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/branches/CLI_1_BRANCH/project.xml?rev=209529r1=209528r2=209529view=diff == --- jakarta/commons/proper/cli/branches/CLI_1_BRANCH/project.xml (original) +++ jakarta/commons/proper/cli/branches/CLI_1_BRANCH/project.xml Wed Jul 6 15:25:19 2005 @@ -18,7 +18,7 @@ pomVersion3/pomVersion idcommons-cli/id nameCLI/name - currentVersion1.0/currentVersion + currentVersion1.1/currentVersion inceptionYear2002/inceptionYear shortDescriptionCommons CLI/shortDescription description @@ -26,6 +26,10 @@ validating a command line interface. /description logo/images/logo.jpg/logo + + versions +version1.0/version + /versions urlhttp://jakarta.apache.org/commons/${pom.artifactId.substring(8)}//url packageorg.apache.commons.${pom.artifactId.substring(8)}/package @@ -93,6 +97,15 @@ organizationintegral Source/organization roles rolecontributed ideas and code from Optz/role + /roles +/developer +developer + nameRob Oxspring/name + idroxspring/id + email[EMAIL PROTECTED]/email + organizationIndigo Stone/organization + roles +roledesigned CLI2/role /roles /developer /developers - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r201494 - /jakarta/commons/proper/cli/branches/commons-configuration-integration/
Author: roxspring Date: Thu Jun 23 14:25:49 2005 New Revision: 201494 URL: http://svn.apache.org/viewcvs?rev=201494view=rev Log: Created branch for the [configuration] integration Added: jakarta/commons/proper/cli/branches/commons-configuration-integration/ - copied from r201493, jakarta/commons/proper/cli/trunk/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r201497 - in /jakarta/commons/proper/cli/branches/commons-configuration-integration: ./ src/java/org/apache/commons/cli2/commandline/ src/test/org/apache/commons/cli2/commandline/
Author: roxspring Date: Thu Jun 23 14:30:40 2005 New Revision: 201497 URL: http://svn.apache.org/viewcvs?rev=201497view=rev Log: Added initial stab at commons-configuration integration Added: jakarta/commons/proper/cli/branches/commons-configuration-integration/src/java/org/apache/commons/cli2/commandline/CommandLineConfiguration.java jakarta/commons/proper/cli/branches/commons-configuration-integration/src/java/org/apache/commons/cli2/commandline/ConfigurationCommandLine.java jakarta/commons/proper/cli/branches/commons-configuration-integration/src/test/org/apache/commons/cli2/commandline/ConfigurationCommandLineTest.java Modified: jakarta/commons/proper/cli/branches/commons-configuration-integration/project.xml Modified: jakarta/commons/proper/cli/branches/commons-configuration-integration/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/branches/commons-configuration-integration/project.xml?rev=201497r1=201496r2=201497view=diff == --- jakarta/commons/proper/cli/branches/commons-configuration-integration/project.xml (original) +++ jakarta/commons/proper/cli/branches/commons-configuration-integration/project.xml Thu Jun 23 14:30:40 2005 @@ -131,6 +131,16 @@ /dependency dependency + idcommons-configuration/id + version1.0/version +/dependency + +dependency + idcommons-collections/id + version3.1/version +/dependency + +dependency idjunit/id version3.8.1/version /dependency Added: jakarta/commons/proper/cli/branches/commons-configuration-integration/src/java/org/apache/commons/cli2/commandline/CommandLineConfiguration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/branches/commons-configuration-integration/src/java/org/apache/commons/cli2/commandline/CommandLineConfiguration.java?rev=201497view=auto == --- jakarta/commons/proper/cli/branches/commons-configuration-integration/src/java/org/apache/commons/cli2/commandline/CommandLineConfiguration.java (added) +++ jakarta/commons/proper/cli/branches/commons-configuration-integration/src/java/org/apache/commons/cli2/commandline/CommandLineConfiguration.java Thu Jun 23 14:30:40 2005 @@ -0,0 +1,75 @@ +/** + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.cli2.commandline; + +import java.util.Iterator; + +import org.apache.commons.cli2.CommandLine; +import org.apache.commons.configuration.AbstractConfiguration; + +/** + * @author roxspring + */ +public class CommandLineConfiguration extends AbstractConfiguration { + + private final CommandLine cmd; + + public CommandLineConfiguration(final CommandLine cmd) { + this.cmd = cmd; + } + + /* (non-Javadoc) +* @see org.apache.commons.configuration.AbstractConfiguration#getPropertyDirect(java.lang.String) +*/ + protected Object getPropertyDirect(String key) { + return cmd.getValue(key); + } + + /* (non-Javadoc) +* @see org.apache.commons.configuration.AbstractConfiguration#addPropertyDirect(java.lang.String, java.lang.Object) +*/ + protected void addPropertyDirect(String key, Object value) { + throw new UnsupportedOperationException(CommandLineConfiguration is currently read only); + } + + /* (non-Javadoc) +* @see org.apache.commons.configuration.AbstractConfiguration#isEmpty() +*/ + public boolean isEmpty() { + return cmd.getOptions().isEmpty(); + } + + /* (non-Javadoc) +* @see org.apache.commons.configuration.AbstractConfiguration#containsKey(java.lang.String) +*/ + public boolean containsKey(String key) { + return cmd.hasOption(key); + } + + /* (non-Javadoc) +* @see org.apache.commons.configuration.AbstractConfiguration#clearProperty(java.lang.String) +*/ + public void clearProperty(String arg0) { + throw new UnsupportedOperationException(CommandLineConfiguration is currently read only); + } + + /* (non-Javadoc) +* @see org.apache.commons.configuration.AbstractConfiguration
svn commit: r191034 - /jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PropertiesCommandLineTest.java
Author: roxspring Date: Thu Jun 16 16:40:58 2005 New Revision: 191034 URL: http://svn.apache.org/viewcvs?rev=191034view=rev Log: Removed out-dated comment Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PropertiesCommandLineTest.java Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PropertiesCommandLineTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PropertiesCommandLineTest.java?rev=191034r1=191033r2=191034view=diff == --- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PropertiesCommandLineTest.java (original) +++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/PropertiesCommandLineTest.java Thu Jun 16 16:40:58 2005 @@ -1,5 +1,5 @@ /** - * Copyright 2004 The Apache Software Foundation + * Copyright 2004-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ * @see org.apache.commons.cli2.CommandLineTest#createCommandLine() */ protected CommandLine createCommandLine() { - // TODO Auto-generated method stub props = new Properties(); props.setProperty(--present,present value); props.setProperty(--alsopresent,); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r190808 - /jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java
Author: roxspring Date: Wed Jun 15 14:11:16 2005 New Revision: 190808 URL: http://svn.apache.org/viewcvs?rev=190808view=rev Log: DocumentationTest now passes again Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java?rev=190808r1=190807r2=190808view=diff == --- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java (original) +++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java Wed Jun 15 14:11:16 2005 @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -27,6 +28,7 @@ import org.apache.commons.cli2.builder.DefaultOptionBuilder; import org.apache.commons.cli2.builder.GroupBuilder; import org.apache.commons.cli2.commandline.Parser; +import org.apache.commons.cli2.commandline.WriteableCommandLineImpl; import org.apache.commons.cli2.option.DefaultOption; import org.apache.commons.cli2.option.PropertyOption; import org.apache.commons.cli2.util.HelpFormatter; @@ -185,7 +187,7 @@ /// try { -Group options = null; +Group options = outputChildren; HelpFormatter hf = new HelpFormatter(); Parser p = new Parser(); @@ -203,7 +205,7 @@ // -CommandLine cl = null; +CommandLine cl = new WriteableCommandLineImpl(outputChildren,new ArrayList()); // if we have --output option if(cl.hasOption(--output)) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r190810 - /jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
Author: roxspring Date: Wed Jun 15 14:20:09 2005 New Revision: 190810 URL: http://svn.apache.org/viewcvs?rev=190810view=rev Log: Parser no longer validates the CommandLine if the help option is found Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java?rev=190810r1=190809r2=190810view=diff == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java Wed Jun 15 14:20:09 2005 @@ -54,26 +54,32 @@ * command line tokens. */ public CommandLine parse(final String[] arguments) throws OptionException { - + +// build a mutable list for the arguments final List argumentList = new LinkedList(Arrays.asList(arguments)); final WriteableCommandLine commandLine = new WriteableCommandLineImpl(group, new ArrayList()); // pick up any defaults from the model group.defaults(commandLine); - + +// process the options as far as possible final ListIterator iterator = argumentList.listIterator(); while (group.canProcess(commandLine, iterator)) { group.process(commandLine, iterator); } - + +// if there are more arguments we have a problem if (iterator.hasNext()) { final String arg = (String)iterator.next(); throw new OptionException(group, cli.error.unexpected, arg); } - -group.validate(commandLine); - + +// no need to validate if the help option is present +if (!commandLine.hasOption(helpOption) !commandLine.hasOption(helpTrigger)) { +group.validate(commandLine); +} + return commandLine; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r190821 - in /jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli2/commandline/Parser.java java/org/apache/commons/cli2/option/GroupImpl.java test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java
Author: roxspring Date: Wed Jun 15 15:13:56 2005 New Revision: 190821 URL: http://svn.apache.org/viewcvs?rev=190821view=rev Log: Fixed second bug where infinite loops could occur. This time it was over eager processing of anonymous arguments in a group. Test case included. Reported by Steve Alberty Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java?rev=190821r1=190820r2=190821view=diff == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java Wed Jun 15 15:13:56 2005 @@ -17,7 +17,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; @@ -56,7 +55,18 @@ public CommandLine parse(final String[] arguments) throws OptionException { // build a mutable list for the arguments -final List argumentList = new LinkedList(Arrays.asList(arguments)); +final List argumentList = new LinkedList(); + +// copy the arguments into the new list +for (int i = 0; i arguments.length; i++) { +final String argument = arguments[i]; + +// ensure non intern'd strings are used +// so that == comparisons work as expected +argumentList.add(new String(argument)); +} + +// wet up a command line for this group final WriteableCommandLine commandLine = new WriteableCommandLineImpl(group, new ArrayList()); @@ -65,7 +75,21 @@ // process the options as far as possible final ListIterator iterator = argumentList.listIterator(); +Object previous = null; while (group.canProcess(commandLine, iterator)) { + +// peek at the next item and backtrack +final Object next = iterator.next(); +iterator.previous(); + +// if we have just tried to process this instance +if(next==previous) { +// abort +break; +} +// remember previous +previous = next; + group.process(commandLine, iterator); } Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java?rev=190821r1=190820r2=190821view=diff == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java Wed Jun 15 15:13:56 2005 @@ -160,11 +160,24 @@ final WriteableCommandLine commandLine, final ListIterator arguments) throws OptionException { + +String previous = null; // [START process each command line token while (arguments.hasNext()) { - + +// grab the next argument final String arg = (String)arguments.next(); + +// if we have just tried to process this instance +if(arg==previous) { +// rollback and abort +arguments.previous(); +break; +} +// remember last processed instance +previous = arg; + final Option opt = (Option)optionMap.get(arg); // option found Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java?rev=190821r1=190820r2=190821view=diff == --- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java (original) +++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java Wed Jun 15 15:13:56 2005 @@ -17,12 +17,14 @@ import junit.framework.TestCase; +import
svn commit: r190828 - in /jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli2/commandline/Parser.java java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java test/org/apache/commons/cli2/commandline/ParserTest.java
Author: roxspring Date: Wed Jun 15 16:11:14 2005 New Revision: 190828 URL: http://svn.apache.org/viewcvs?rev=190828view=rev Log: Parser now keeps the normalised list of arguments. Added ParserTest Added: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/ParserTest.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java?rev=190828r1=190827r2=190828view=diff == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java Wed Jun 15 16:11:14 2005 @@ -16,7 +16,6 @@ package org.apache.commons.cli2.commandline; import java.io.IOException; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; @@ -68,7 +67,7 @@ // wet up a command line for this group final WriteableCommandLine commandLine = -new WriteableCommandLineImpl(group, new ArrayList()); +new WriteableCommandLineImpl(group, argumentList); // pick up any defaults from the model group.defaults(commandLine); Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java?rev=190828r1=190827r2=190828view=diff == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java Wed Jun 15 16:11:14 2005 @@ -204,4 +204,9 @@ defaultSwitches.put(option, defaultSwitch); } } + +public List getNormalised() { +return Collections.unmodifiableList(normalised); +} + } Added: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/ParserTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/ParserTest.java?rev=190828view=auto == --- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/ParserTest.java (added) +++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/ParserTest.java Wed Jun 15 16:11:14 2005 @@ -0,0 +1,124 @@ +package org.apache.commons.cli2.commandline; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringReader; +import java.io.StringWriter; + +import org.apache.commons.cli2.CommandLine; +import org.apache.commons.cli2.Group; +import org.apache.commons.cli2.OptionException; +import org.apache.commons.cli2.builder.DefaultOptionBuilder; +import org.apache.commons.cli2.builder.GroupBuilder; +import org.apache.commons.cli2.option.DefaultOption; +import org.apache.commons.cli2.util.HelpFormatter; + +import junit.framework.TestCase; + +public class ParserTest extends TestCase { + +private Parser parser; +private DefaultOption verboseOption; +private DefaultOption helpOption; +private Group options; +private HelpFormatter helpFormatter; +private StringWriter out; +private BufferedReader in; + +public void setUp() { +parser = new Parser(); + +final GroupBuilder gBuilder = new GroupBuilder(); +final DefaultOptionBuilder oBuilder = new DefaultOptionBuilder(); + +helpOption = oBuilder.withLongName(help).withShortName(h).create(); +verboseOption = oBuilder.withLongName(verbose).withShortName(v).create(); +options = gBuilder.withOption(helpOption).withOption(verboseOption).create(); +parser.setGroup(options); + +helpFormatter = new HelpFormatter(); +out = new StringWriter(); +helpFormatter.setPrintWriter(new PrintWriter(out)); +parser.setHelpFormatter(helpFormatter); +} + +public void testParse_Successful() throws OptionException { +final CommandLine cl = parser.parse(new String[]{-hv}); + +assertTrue(cl.hasOption(helpOption)); +assertTrue(cl.hasOption(verboseOption)); + +assertEquals(--help --verbose,cl.toString
svn commit: r179892 - in /jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli2/ java/org/apache/commons/cli2/commandline/ java/org/apache/commons/cli2/option/ test/org/apache/commons/cli2/bug/ test/org/apache/commons/cli2/option/
Author: roxspring Date: Fri Jun 3 14:15:13 2005 New Revision: 179892 URL: http://svn.apache.org/viewcvs?rev=179892view=rev Log: GroupImpl.canProcess() was returning true when the argument looked like an option but wasn't accepted by the children. Option.canProcess() now takes a WriteableCommandLine to provide the looksLikeOption() method. Bug discovered by Steve Alberty Added: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ArgumentImpl.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Command.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/DefaultOption.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/OptionImpl.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ParentImpl.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/SourceDestArgument.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Switch.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTest.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/CommandTest.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/DefaultOptionTest.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTest.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTest.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/SwitchTest.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java?rev=179892r1=179891r2=179892view=diff == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java Fri Jun 3 14:15:13 2005 @@ -1,5 +1,5 @@ /** - * Copyright 2003-2004 The Apache Software Foundation + * Copyright 2003-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ *The argument to be tested * @return true if the argument can be processed by this Option */ -boolean canProcess(final String argument); +boolean canProcess(final WriteableCommandLine commandLine, final String argument); /** * Indicates whether this Option will be able to process the particular @@ -77,7 +77,7 @@ *the ListIterator over String arguments * @return true if the argument can be processed by this Option */ -boolean canProcess(final ListIterator arguments); +boolean canProcess(final WriteableCommandLine commandLine, final ListIterator arguments); /** * Identifies the argument prefixes that should trigger this option. This Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java?rev=179892r1=179891r2=179892view=diff == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java Fri Jun 3 14:15:13 2005 @@ -1,5 +1,5 @@ /** - * Copyright 2003-2004 The Apache Software Foundation + * Copyright 2003-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ group.defaults(commandLine); final ListIterator iterator = argumentList.listIterator(); -while (group.canProcess(iterator)) { +while (group.canProcess(commandLine, iterator)) { group.process(commandLine, iterator); } Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option
svn commit: r179898 [1/2] - in /jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli/avalon/ test/org/apache/commons/cli/avalon/
Author: roxspring Date: Fri Jun 3 14:57:28 2005 New Revision: 179898 URL: http://svn.apache.org/viewcvs?rev=179898view=rev Log: Added the old Avalon Excalibur CLI package Submitted by: Sebb Issue: 34672 Added: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/AbstractParserControl.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLArgsParser.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLOption.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLOptionDescriptor.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLUtil.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/ParserControl.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/Token.java jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/package.html jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli/avalon/ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli/avalon/ClutilTestCase.java Added: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/AbstractParserControl.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/AbstractParserControl.java?rev=179898view=auto == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/AbstractParserControl.java (added) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/AbstractParserControl.java Fri Jun 3 14:57:28 2005 @@ -0,0 +1,40 @@ +/* + * Copyright 2002-2005 The Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.cli.avalon; +//Renamed from org.apache.avalon.excalibur.cli + +/** + * Class to inherit from so when in future when new controls are added + * clients will no have to implement them. + * @version $Revision: 1.2 $ + * @see ParserControl + */ +public abstract class AbstractParserControl +implements ParserControl +{ +/** + * By default always continue parsing by returning false. + * + * @param lastOptionCode the code of last option parsed + * @return return true to halt, false to continue parsing + * @see ParserControl#isFinished(int) + */ +public boolean isFinished( int lastOptionCode ) +{ +return false; +} +} Added: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLArgsParser.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLArgsParser.java?rev=179898view=auto == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLArgsParser.java (added) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli/avalon/CLArgsParser.java Fri Jun 3 14:57:28 2005 @@ -0,0 +1,810 @@ +/* + * Copyright 2002-2005 The Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.cli.avalon; +//Renamed from org.apache.avalon.excalibur.cli + +import java.text.ParseException; +import java.util.Hashtable; +import java.util.Vector; + +/** + * Parser for command line arguments. + * + * This parses command lines according to the standard (?) of + * GNU utilities. + * + * Note: This is still used in 1.1 libraries so do not add 1.2+ dependencies. + * + * Note that CLArgs uses a backing hashtable for the options index and so duplicate + * arguments are only returned by getArguments(). + * + * @version $Revision: 1.2 $ $Date: 2005/03/18 15:26:55 $ + * @see
svn commit: r179898 [2/2] - in /jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli/avalon/ test/org/apache/commons/cli/avalon/
Added: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli/avalon/ClutilTestCase.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli/avalon/ClutilTestCase.java?rev=179898view=auto == --- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli/avalon/ClutilTestCase.java (added) +++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli/avalon/ClutilTestCase.java Fri Jun 3 14:57:28 2005 @@ -0,0 +1,1022 @@ +/* + * Copyright 2002-2005 The Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.cli.avalon; +//Renamed from org.apache.avalon.excalibur.cli + +import java.util.List; + +import junit.framework.TestCase; + +/** + * + */ +public final class ClutilTestCase +extends TestCase +{ +private static final String[] ARGLIST1 = new String[] +{ +--you, are, --all, -cler, kid +}; + +private static final String[] ARGLIST2 = new String[] +{ +-Dstupid=idiot, are, --all, here, -d +}; + +private static final String[] ARGLIST3 = new String[] +{ +//duplicates +-Dstupid=idiot, are, --all, --all, here +}; + +private static final String[] ARGLIST4 = new String[] +{ +//incompatable (blee/all) +-Dstupid,idiot, are, --all, --blee, here +}; + +private static final String[] ARGLIST5 = new String[] +{ +-f, myfile.txt +}; + +private static final int DEFINE_OPT = 'D'; +private static final int CASE_CHECK_OPT = 'd'; +private static final int YOU_OPT = 'y'; +private static final int ALL_OPT = 'a'; +private static final int CLEAR1_OPT = 'c'; +private static final int CLEAR2_OPT = 'l'; +private static final int CLEAR3_OPT = 'e'; +private static final int CLEAR5_OPT = 'r'; +private static final int BLEE_OPT = 'b'; +private static final int FILE_OPT = 'f'; +private static final int TAINT_OPT = 'T'; + +private static final CLOptionDescriptor DEFINE = +new CLOptionDescriptor( define, +CLOptionDescriptor.ARGUMENTS_REQUIRED_2, +DEFINE_OPT, +define ); +private static final CLOptionDescriptor DEFINE_MANY = +new CLOptionDescriptor( define, + CLOptionDescriptor.ARGUMENTS_REQUIRED_2|CLOptionDescriptor.DUPLICATES_ALLOWED, + DEFINE_OPT, + define ); + +private static final CLOptionDescriptor CASE_CHECK = +new CLOptionDescriptor( charCheck, +CLOptionDescriptor.ARGUMENT_DISALLOWED, +CASE_CHECK_OPT, +check character case sensitivity ); +private static final CLOptionDescriptor YOU = +new CLOptionDescriptor( you, CLOptionDescriptor.ARGUMENT_DISALLOWED, YOU_OPT, you ); + +private static final CLOptionDescriptor CLEAR1 = +new CLOptionDescriptor( c, CLOptionDescriptor.ARGUMENT_DISALLOWED, CLEAR1_OPT, c ); +private static final CLOptionDescriptor CLEAR2 = +new CLOptionDescriptor( l, CLOptionDescriptor.ARGUMENT_DISALLOWED, CLEAR2_OPT, l ); +private static final CLOptionDescriptor CLEAR3 = +new CLOptionDescriptor( e, CLOptionDescriptor.ARGUMENT_DISALLOWED, CLEAR3_OPT, e ); +private static final CLOptionDescriptor CLEAR5 = +new CLOptionDescriptor( r, CLOptionDescriptor.ARGUMENT_DISALLOWED, CLEAR5_OPT, r ); +private static final CLOptionDescriptor BLEE = +new CLOptionDescriptor( blee, +CLOptionDescriptor.ARGUMENT_DISALLOWED, +BLEE_OPT, +blee ); + +private static final CLOptionDescriptor ALL = +new CLOptionDescriptor( all, +CLOptionDescriptor.ARGUMENT_DISALLOWED, +ALL_OPT, +all, +new CLOptionDescriptor[]{BLEE} ); + +private static final CLOptionDescriptor FILE = +new CLOptionDescriptor( file, +CLOptionDescriptor.ARGUMENT_REQUIRED, +FILE_OPT, +the build file. ); +private static final CLOptionDescriptor TAINT = +new CLOptionDescriptor( taint, +CLOptionDescriptor.ARGUMENT_OPTIONAL, +
svn commit: r179921 - in /jakarta/commons/proper/cli/trunk: src/test/org/apache/commons/cli2/DocumentationTest.java xdocs/manual/index.xml
Author: roxspring Date: Fri Jun 3 18:09:22 2005 New Revision: 179921 URL: http://svn.apache.org/viewcvs?rev=179921view=rev Log: Added CLI2 Overview documentation Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java jakarta/commons/proper/cli/trunk/xdocs/manual/index.xml Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java?rev=179921r1=179920r2=179921view=diff == --- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java (original) +++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/DocumentationTest.java Fri Jun 3 18:09:22 2005 @@ -27,6 +27,7 @@ import org.apache.commons.cli2.builder.DefaultOptionBuilder; import org.apache.commons.cli2.builder.GroupBuilder; import org.apache.commons.cli2.commandline.Parser; +import org.apache.commons.cli2.option.DefaultOption; import org.apache.commons.cli2.option.PropertyOption; import org.apache.commons.cli2.util.HelpFormatter; @@ -147,6 +148,81 @@ Unexpected --bad-option while processing options, uoe.getMessage()); } +} + +public void testManualIntroduction() { + +DefaultOptionBuilder oBuilder = new DefaultOptionBuilder(); +ArgumentBuilder aBuilder = new ArgumentBuilder(); +GroupBuilder gBuilder = new GroupBuilder(); + +DefaultOption xmlOption = +oBuilder +.withLongName(xml) +.withDescription(Output using xml format) +.create(); + +Argument pathArgument = +aBuilder +.withName(path) +.withMinimum(1) +.withMaximum(1) +.create(); + +Group outputChildren = +gBuilder +.withOption(xmlOption) +.create(); + +Option outputOption = +oBuilder +.withLongName(output) +.withDescription(Outputs to a file) +.withArgument(pathArgument) +.withChildren(outputChildren) +.create(); + +/// + +try { +Group options = null; +HelpFormatter hf = new HelpFormatter(); + +Parser p = new Parser(); +p.setGroup(options); +p.setHelpFormatter(hf); +p.setHelpTrigger(--help); +CommandLine cl = p.parseAndHelp(new String[]{}); +if(cl==null) { +System.exit(-1); +} +} catch (IOException e) { +// TODO Auto-generated catch block +e.printStackTrace(); +} + +// + +CommandLine cl = null; + +// if we have --output option +if(cl.hasOption(--output)) { +// grab the path +String path = (String)cl.getValue(--output); +// grab the format +boolean xml = cl.hasOption(--xml); +// configure the application's output +configureOutput(path,xml); +} + + + + +} + +private void configureOutput(String path, boolean xml) { +// TODO Auto-generated method stub + } public void testExampleAnt() throws IOException, OptionException { Modified: jakarta/commons/proper/cli/trunk/xdocs/manual/index.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/xdocs/manual/index.xml?rev=179921r1=179920r2=179921view=diff == --- jakarta/commons/proper/cli/trunk/xdocs/manual/index.xml (original) +++ jakarta/commons/proper/cli/trunk/xdocs/manual/index.xml Fri Jun 3 18:09:22 2005 @@ -1,6 +1,6 @@ ?xml version=1.0? !-- - Copyright 2004 The Apache Software Foundation + Copyright 2004-2005 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. @@ -15,29 +15,178 @@ limitations under the License. -- document + +properties +author email=commons-dev@jakarta.apache.orgcommons-dev/author +titleCLI2 - Overview/title +/properties + +body +section name=Overview +p +CLI Breaks down command line processing into three distinct phases, the +first of which is to create a model of the command line you wish to process. The +second phase is arguably the most important
svn commit: r179922 - /jakarta/commons/proper/cli/trunk/xdocs/usage.xml
Author: roxspring Date: Fri Jun 3 18:12:01 2005 New Revision: 179922 URL: http://svn.apache.org/viewcvs?rev=179922view=rev Log: Corrected CLI1 usage mistakes Submitted by: Liu yehui Issue: 35191 Modified: jakarta/commons/proper/cli/trunk/xdocs/usage.xml Modified: jakarta/commons/proper/cli/trunk/xdocs/usage.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/xdocs/usage.xml?rev=179922r1=179921r2=179922view=diff == --- jakarta/commons/proper/cli/trunk/xdocs/usage.xml (original) +++ jakarta/commons/proper/cli/trunk/xdocs/usage.xml Fri Jun 3 18:12:01 2005 @@ -166,7 +166,7 @@ sourceOption logfile = OptionBuilder.withArgName( file ) .hasArg() .withDescription( use given file for log ) -.create( file ); +.create( logfile ); Option logger= OptionBuilder.withArgName( classname ) .hasArg() @@ -189,7 +189,7 @@ .hasArg() .withDescription( search for buildfile towards the + root of the filesystem and use it ) -.create( file );/source +.create( find );/source /subsection subsection name=Java Property Option p - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r161579 - in jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli2/util/HelpFormatter.java test/org/apache/commons/cli2/util/HelpFormatterTest.java
Author: roxspring Date: Sat Apr 16 08:40:32 2005 New Revision: 161579 URL: http://svn.apache.org/viewcvs?view=revrev=161579 Log: Long descriptions with newlines are now correctly formatted Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java?view=diffr1=161578r2=161579 == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java Sat Apr 16 08:40:32 2005 @@ -362,10 +362,10 @@ while (left chars.length) { int right = left; -while (right chars.length chars[right] != '\n') { +while (right chars.length chars[right] != '\n' rightleft+width+1) { right++; } -if (right chars.length) { +if (rightchars.length chars[right] == '\n') { final String line = new String(chars, left, right - left); lines.add(line); left = right + 1; Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java?view=diffr1=161578r2=161579 == --- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java (original) +++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java Sat Apr 16 08:40:32 2005 @@ -21,6 +21,7 @@ import java.io.StringReader; import java.io.StringWriter; import java.util.Iterator; +import java.util.List; import junit.framework.TestCase; @@ -343,6 +344,23 @@ assertEquals(, i.next()); assertEquals(Apache Software Foundation, i.next()); assertEquals(, i.next()); +assertFalse(i.hasNext()); +} + +public void testWrap_NewLine2() { +List wrapped = HelpFormatter.wrap(A really quite long general description of the option with specific alternatives documented:\n+ + Indented special case\n+ + Alternative scenario, 30); + +final Iterator i = +wrapped.iterator(); + +assertEquals(A really quite long general, i.next()); +assertEquals(description of the option, i.next()); +assertEquals(with specific alternatives, i.next()); +assertEquals(documented:, i.next()); +assertEquals( Indented special case, i.next()); +assertEquals( Alternative scenario, i.next()); assertFalse(i.hasNext()); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r161581 - jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
Author: roxspring Date: Sat Apr 16 09:24:01 2005 New Revision: 161581 URL: http://svn.apache.org/viewcvs?view=revrev=161581 Log: Commented the more complex methods Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java?view=diffr1=161580r2=161581 == --- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java (original) +++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java Sat Apr 16 09:24:01 2005 @@ -143,6 +143,8 @@ final String gutterCenter, final String gutterRight, final int fullWidth) { + +// default the left gutter to empty string if (gutterLeft == null) { this.gutterLeft = ; } @@ -150,6 +152,7 @@ this.gutterLeft = gutterLeft; } +// default the center gutter to empty string if (gutterCenter == null) { this.gutterCenter = ; } @@ -157,6 +160,7 @@ this.gutterCenter = gutterCenter; } +// default the right gutter to empty string if (gutterRight == null) { this.gutterRight = ; } @@ -164,7 +168,10 @@ this.gutterRight = gutterRight; } +// calculate the available page width this.pageWidth = fullWidth - gutterLeft.length() - gutterRight.length(); + +// check available page width is valid if (fullWidth - pageWidth + gutterCenter.length() 2) { throw new IllegalArgumentException( The gutter strings leave no space for output! @@ -210,39 +217,54 @@ else { option = group; } - + +// grab the HelpLines to display final List helpLines = option.helpLines(0, displaySettings, comparator); + +// calculate the maximum width of the usage strings int usageWidth = 0; for (final Iterator i = helpLines.iterator(); i.hasNext();) { final HelpLine helpLine = (HelpLine)i.next(); final String usage = helpLine.usage(lineUsageSettings, comparator); usageWidth = Math.max(usageWidth, usage.length()); } + +// build a blank string to pad wrapped descriptions final StringBuffer blankBuffer = new StringBuffer(); for (int i = 0; i usageWidth; i++) { blankBuffer.append(' '); } + +// determine the width available for descriptions final int descriptionWidth = Math.max(1, pageWidth - gutterCenter.length() - usageWidth); + +// display each HelpLine for (final Iterator i = helpLines.iterator(); i.hasNext();) { + +// grab the HelpLine final HelpLine helpLine = (HelpLine)i.next(); -final List descriptionLines = + +// wrap the description +final List descList = wrap(helpLine.getDescription(), descriptionWidth); -final Iterator j = descriptionLines.iterator(); +final Iterator descriptionIterator = descList.iterator(); +// display usage + first line of description printGutterLeft(); pad(helpLine.usage(lineUsageSettings, comparator), usageWidth, out); out.print(gutterCenter); -pad((String)j.next(), descriptionWidth, out); +pad((String)descriptionIterator.next(), descriptionWidth, out); printGutterRight(); out.println(); -while (j.hasNext()) { +// display padding + remaining lines of description +while (descriptionIterator.hasNext()) { printGutterLeft(); //pad(helpLine.getUsage(),usageWidth,out); out.print(blankBuffer); out.print(gutterCenter); -pad((String)j.next(), descriptionWidth, out); +pad((String)descriptionIterator.next(), descriptionWidth, out); printGutterRight(); out.println(); } @@ -333,7 +355,9 @@ final int width, final Writer writer) throws IOException { -int left; +final int left; + +// write the text and record how many characters written if (text == null) { left = 0; } @@ -342,16 +366,20 @@ left = text.length(); } +// pad remainder with spaces for (int i = left; i width; ++i) { writer.write
svn commit: r161460 - jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java
Author: roxspring Date: Fri Apr 15 06:51:30 2005 New Revision: 161460 URL: http://svn.apache.org/viewcvs?view=revrev=161460 Log: The underlying InputStream really should be closed Modified: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java Modified: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java?view=diffr1=161459r2=161460 == --- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java (original) +++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java Fri Apr 15 06:51:30 2005 @@ -964,4 +964,9 @@ } } } + +public void close() throws IOException +{ +m_input.close(); +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r160399 - jakarta/commons/proper/cli/trunk/maven.xml
Author: roxspring Date: Thu Apr 7 03:13:56 2005 New Revision: 160399 URL: http://svn.apache.org/viewcvs?view=revrev=160399 Log: NOTICE file now included in distributions Modified: jakarta/commons/proper/cli/trunk/maven.xml Modified: jakarta/commons/proper/cli/trunk/maven.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/maven.xml?view=diffr1=160398r2=160399 == --- jakarta/commons/proper/cli/trunk/maven.xml (original) +++ jakarta/commons/proper/cli/trunk/maven.xml Thu Apr 7 03:13:56 2005 @@ -32,6 +32,23 @@ !-- END: C O M M O N S - B U I L D -- !-- == -- + !-- Ensures that the conf directory and NOTICE.txt are included in the + source distro. + -- + postGoal name=dist:prepare-src-filesystem +copy todir=${maven.dist.src.assembly.dir} + fileset file=${basedir}/NOTICE.txt/ +/copy + /postGoal + + !-- Ensures that NOTICE.txt is added to the binary distro -- + preGoal name=dist:build-bin +copy todir=${maven.dist.bin.assembly.dir} + fileset file=${basedir}/NOTICE.txt/ +/copy + /preGoal + + postGoal name=xdoc:transform attainGoal name=pdf:pdf/ /postGoal - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r160317 - jakarta/commons/proper/cli/trunk/maven.xml
Author: roxspring Date: Wed Apr 6 11:45:19 2005 New Revision: 160317 URL: http://svn.apache.org/viewcvs?view=revrev=160317 Log: Ensure uptodate build.xml when creating distributions Modified: jakarta/commons/proper/cli/trunk/maven.xml Modified: jakarta/commons/proper/cli/trunk/maven.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/maven.xml?view=diffr1=160316r2=160317 == --- jakarta/commons/proper/cli/trunk/maven.xml (original) +++ jakarta/commons/proper/cli/trunk/maven.xml Wed Apr 6 11:45:19 2005 @@ -1,6 +1,6 @@ !-- Copyright 2002-2004 The Apache Software Foundation. - + Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -20,18 +20,18 @@ !-- == -- !-- Required: Look and Feel for documentation within distributions -- !-- == -- - postGoal name=xdoc:copy-resources + postGoal name=xdoc:copy-resources copy todir=${basedir}/target/docs/style/ failonerror=false fileset dir=${basedir}/../commons-build/xdocs/style - include name='**/*'/ - exclude name='**/CVS/**'/ +include name='**/*'/ +exclude name='**/CVS/**'/ /fileset /copy /postGoal !-- == -- !-- END: C O M M O N S - B U I L D -- !-- == -- - + postGoal name=xdoc:transform attainGoal name=pdf:pdf/ /postGoal @@ -39,6 +39,14 @@ preGoal name=pdf:prepare attainGoal name=svg:init/ attainGoal name=svg:convert/ + /preGoal + + preGoal name=dist:prepare-bin-filesystem + attainGoal name=ant:generate-build/ + /preGoal + + preGoal name=dist:prepare-src-filesystem + attainGoal name=ant:generate-build/ /preGoal /project - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r160320 - jakarta/commons/proper/cli/trunk/project.xml
Author: roxspring Date: Wed Apr 6 12:14:14 2005 New Revision: 160320 URL: http://svn.apache.org/viewcvs?view=revrev=160320 Log: JavaDocs need to cover o.a.c.cli2* in addition to o.a.c.cli Modified: jakarta/commons/proper/cli/trunk/project.xml Modified: jakarta/commons/proper/cli/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/project.xml?view=diffr1=160319r2=160320 == --- jakarta/commons/proper/cli/trunk/project.xml (original) +++ jakarta/commons/proper/cli/trunk/project.xml Wed Apr 6 12:14:14 2005 @@ -27,7 +27,7 @@ logo/images/logo.jpg/logo urlhttp://jakarta.apache.org/commons/${pom.artifactId.substring(8)}//url - packageorg.apache.commons.${pom.artifactId.substring(8)}/package + packageorg.apache.commons/package organization nameApache Software Foundation/name - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r160202 - in jakarta/commons/proper/io/trunk: project.xml src/java/org/apache/commons/io/input/CountingInputStream.java src/test/org/apache/commons/io/input/CountingInputStreamTest.java
Author: roxspring Date: Tue Apr 5 10:22:21 2005 New Revision: 160202 URL: http://svn.apache.org/viewcvs?view=revrev=160202 Log: CountingInputStream now implements skip(long) method. PR: 34311 Modified: jakarta/commons/proper/io/trunk/project.xml jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java Modified: jakarta/commons/proper/io/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/project.xml?view=diffr1=160201r2=160202 == --- jakarta/commons/proper/io/trunk/project.xml (original) +++ jakarta/commons/proper/io/trunk/project.xml Tue Apr 5 10:22:21 2005 @@ -16,7 +16,7 @@ -- project pomVersion3/pomVersion - + nameIO/name idcommons-io/id currentVersion1.1-dev/currentVersion @@ -26,7 +26,7 @@ Commons-IO contains utility classes, stream implementations, file filters, and endian classes. /description logo/images/io-logo-white.png/logo - + urlhttp://jakarta.apache.org/commons/${pom.artifactId.substring(8)}//url packageorg.apache.commons.${pom.artifactId.substring(8)}/package @@ -43,18 +43,18 @@ distributionrepo/distribution /license /licenses - + gumpRepositoryIdjakarta/gumpRepositoryId issueTrackingUrlhttp://issues.apache.org/bugzilla//issueTrackingUrl siteAddressjakarta.apache.org/siteAddress siteDirectory/www/jakarta.apache.org/commons/${pom.artifactId.substring(8)}//siteDirectory distributionDirectory/www/jakarta.apache.org/builds/jakarta-commons/${pom.artifactId.substring(8)}//distributionDirectory - + repository connectionscm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk/connection urlhttp://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk/url /repository - + mailingLists mailingList nameCommons Dev List/name @@ -69,7 +69,7 @@ archivehttp://mail-archives.apache.org/eyebrowse/[EMAIL PROTECTED]/archive /mailingList /mailingLists - + versions version id1.0/id @@ -146,6 +146,15 @@ nameMartin Cooper/name idmartinc/id email[EMAIL PROTECTED]/email + organization/ + roles +roleJava Developer/role + /roles +/developer +developer + nameRob Oxspring/name + idroxspring/id + email[EMAIL PROTECTED]/email organization/ roles roleJava Developer/role Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java?view=diffr1=160201r2=160202 == --- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java (original) +++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java Tue Apr 5 10:22:21 2005 @@ -71,6 +71,17 @@ this.count += (found = 0) ? 1 : 0; return found; } + +/** + * Increases the count by the number of skipped bytes. + * + * @see java.io.InputStream#skip(long) + */ +public long skip(final long length) throws IOException { +final long skip = super.skip(length); +this.count += skip; +return skip; +} /** * The number of bytes that have passed through this stream. Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java?view=diffr1=160201r2=160202 == --- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java (original) +++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/CountingInputStreamTest.java Tue Apr 5 10:22:21 2005 @@ -17,6 +17,8 @@ package org.apache.commons.io.input; import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Arrays; import junit.framework.TestCase; @@ -148,6 +150,21 @@ int found = cis.read(result, 0, 5); assertEquals(2, found); assertEquals(2, cis.getCount()); +} + +public void testSkipping() throws IOException { +String text = Hello World!; +byte[] bytes = text.getBytes(); +ByteArrayInputStream bais = new ByteArrayInputStream(bytes); +CountingInputStream cis = new CountingInputStream(bais); + +assertEquals(6,cis.skip(6)); +assertEquals(6
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2 CLITestCase.java
roxspring2004/12/27 03:55:12 Modified:cli/src/test/org/apache/commons/cli2 CLITestCase.java Log: CLITestCase is now abstract to stop eclipse 3.1 complaining about it having no tests Revision ChangesPath 1.3 +1 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/CLITestCase.java Index: CLITestCase.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/CLITestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CLITestCase.java 22 Apr 2004 23:00:06 - 1.2 +++ CLITestCase.java 27 Dec 2004 11:55:12 - 1.3 @@ -24,7 +24,7 @@ import junit.framework.TestCase; -public class CLITestCase extends TestCase { +public abstract class CLITestCase extends TestCase { public static List list() { return Collections.EMPTY_LIST; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli LongOptionWithShort.java ArgumentIsOptionTest.java
roxspring2004/12/27 04:42:38 Modified:cli/src/java/org/apache/commons/cli PosixParser.java Added: cli/src/test/org/apache/commons/cli LongOptionWithShort.java ArgumentIsOptionTest.java Log: Stops the PosixParser from bursting options unecessarily, i.e. if -file is an acceptible option then it won't be broken into -f -i -l -e. PR: 32525 Submitted by: David Morris Revision ChangesPath 1.16 +4 -2 jakarta-commons/cli/src/java/org/apache/commons/cli/PosixParser.java Index: PosixParser.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/PosixParser.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PosixParser.java 22 Apr 2004 23:00:09 - 1.15 +++ PosixParser.java 27 Dec 2004 12:42:38 - 1.16 @@ -135,7 +135,9 @@ { processOptionToken(token, stopAtNonOption); } - +else if (options.hasOption(token)) { + tokens.add(token); +} // requires bursting else { 1.1 jakarta-commons/cli/src/test/org/apache/commons/cli/LongOptionWithShort.java Index: LongOptionWithShort.java === /** * Copyright 2001-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.cli; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * p * This is a collection of tests that test real world * applications command lines focusing on options with * long and short names. * /p */ public class LongOptionWithShort extends TestCase { public LongOptionWithShort(String name) { super(name); } public static Test suite() { return new TestSuite(LongOptionWithShort.class); } /** * */ public void testLongOptionWithShort() { Option help = new Option(h, help, false, print this message); Option version = new Option(v, version, false, print version information); Option newRun = new Option(n, new, false, Create NLT cache entries only for new items); Option trackerRun = new Option(t, tracker, false, Create NLT cache entries only for tracker items); Option timeLimit = OptionBuilder.withLongOpt(limit).hasArg() .withValueSeparator() .withDescription(Set time limit for execution, in mintues) .create(l); Option age = OptionBuilder.withLongOpt(age).hasArg() .withValueSeparator() .withDescription(Age (in days) of cache item before being recomputed) .create(a); Option server = OptionBuilder.withLongOpt(server).hasArg() .withValueSeparator() .withDescription(The NLT server address) .create(s); Option numResults = OptionBuilder.withLongOpt(results).hasArg() .withValueSeparator() .withDescription(Number of results per item) .create(r); Option configFile = OptionBuilder.withLongOpt(file).hasArg() .withValueSeparator() .withDescription(Use the specified configuration file) .create(); Options options = new Options(); options.addOption(help); options.addOption(version); options.addOption(newRun); options.addOption(trackerRun); options.addOption(timeLimit); options.addOption(age); options.addOption(server); options.addOption(numResults); options.addOption(configFile
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli ArgumentIsOptionTest.java
roxspring2004/12/27 05:11:39 Modified:cli/src/test/org/apache/commons/cli2/jdepend JDependTest.java cli/src/java/org/apache/commons/cli Parser.java cli/src/test/org/apache/commons/cli2 CommandLineTestCase.java cli/src/test/org/apache/commons/cli ArgumentIsOptionTest.java Log: Parser now correctly allows option arguments to be the same as other options, less the initial '-'. E.g. with options -a, the value 'a' is now allowed. Also corrected typo in test: testNoCyclesPresnet(). PR: 25044 Submitted by: David Morris Revision ChangesPath 1.3 +1 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/jdepend/JDependTest.java Index: JDependTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/jdepend/JDependTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JDependTest.java 22 Apr 2004 23:00:16 - 1.2 +++ JDependTest.java 27 Dec 2004 13:11:39 - 1.3 @@ -71,7 +71,7 @@ } } -public void testNoCyclesPresnet() { +public void testNoCyclesPresent() { assertEquals(Cycles exist, false, dependancies.containsCycles()); } 1.16 +3 -2 jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java Index: Parser.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- Parser.java 22 Apr 2004 23:00:09 - 1.15 +++ Parser.java 27 Dec 2004 13:11:39 - 1.16 @@ -319,7 +319,8 @@ { String str = (String) iter.next(); -// found an Option +// found an Option, not an argument +//if (options.hasOption(str) str.startsWith(-)) if (options.hasOption(str)) { iter.previous(); 1.4 +27 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/CommandLineTestCase.java Index: CommandLineTestCase.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/CommandLineTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CommandLineTestCase.java 2 Oct 2004 13:16:21 - 1.3 +++ CommandLineTestCase.java 27 Dec 2004 13:11:39 - 1.4 @@ -19,6 +19,7 @@ import java.util.Iterator; import java.util.List; +import org.apache.commons.cli2.builder.ArgumentBuilder; import org.apache.commons.cli2.builder.DefaultOptionBuilder; import org.apache.commons.cli2.builder.GroupBuilder; import org.apache.commons.cli2.commandline.Parser; @@ -483,5 +484,31 @@ assertEquals(1, cl.getOptionCount(login)); assertEquals(3, cl.getOptionCount(-?)); assertEquals(1, cl.getOptionCount(+display)); +} + +public final void testOptionAsArgument() throws OptionException { + final Option bool = new DefaultOptionBuilder().withShortName(p).create(); + final Argument argument = new ArgumentBuilder().create(); + final Option withArgument = new DefaultOptionBuilder().withShortName(attr).withArgument(argument).create(); + + final Group group = +new GroupBuilder() +.withOption(bool) +.withOption(withArgument) +.create(); + +final Parser parser = new Parser(); +parser.setGroup(group); +final CommandLine cl = +parser.parse( +new String[] { +-p, +-attr, +p }); + +assertEquals(1, cl.getOptionCount(-p)); +assertTrue(cl.hasOption(-p)); +assertTrue(cl.hasOption(-attr)); +assertTrue(cl.getValue(-attr).equals(p)); } } 1.2 +4 -4 jakarta-commons/cli/src/test/org/apache/commons/cli/ArgumentIsOptionTest.java Index: ArgumentIsOptionTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/ArgumentIsOptionTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ArgumentIsOptionTest.java 27 Dec 2004 12:42:38 - 1.1 +++ ArgumentIsOptionTest.java 27 Dec 2004 13:11:39 - 1.2 @@ -46,7 +46,7 @@ String[] args = new String[] { -p, -attr, -value +p }; try
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli Parser.java
roxspring2004/12/27 05:21:17 Modified:cli/src/java/org/apache/commons/cli Parser.java Log: Recommitted with the fix applied not commented out (whoops) PR: 25044 Revision ChangesPath 1.17 +2 -3 jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java Index: Parser.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- Parser.java 27 Dec 2004 13:11:39 - 1.16 +++ Parser.java 27 Dec 2004 13:21:17 - 1.17 @@ -320,8 +320,7 @@ String str = (String) iter.next(); // found an Option, not an argument -//if (options.hasOption(str) str.startsWith(-)) -if (options.hasOption(str)) +if (options.hasOption(str) str.startsWith(-)) { iter.previous(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli BugsTest.java
roxspring2004/12/27 05:33:48 Modified:cli/src/test/org/apache/commons/cli BugsTest.java Log: Added test to demonstrate the 27635 has been fixed PR: 27635 Revision ChangesPath 1.20 +69 -0 jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java Index: BugsTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- BugsTest.java 6 Sep 2004 22:51:45 - 1.19 +++ BugsTest.java 27 Dec 2004 13:33:48 - 1.20 @@ -17,6 +17,7 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.io.PrintWriter; import java.io.StringWriter; import junit.framework.Test; @@ -409,6 +410,74 @@ options.addOption( m ); CommandLine line = parser.parse( options, args ); assertEquals( Two Words, line.getOptionValue( m ) ); +} + +public void test27635() { +Option help = new Option(h, help, false, print this message); +Option version = new Option(v, version, false, print version information); +Option newRun = new Option(n, new, false, Create NLT cache entries only for new items); +Option trackerRun = new Option(t, tracker, false, Create NLT cache entries only for tracker items); + +Option timeLimit = OptionBuilder.withLongOpt(limit) +.hasArg() +.withValueSeparator() +.withDescription(Set time limit for execution, in mintues) +.create(l); + +Option age = OptionBuilder.withLongOpt(age) +.hasArg() +.withValueSeparator() +.withDescription(Age (in days) of cache item before being recomputed) +.create(a); + +Option server = OptionBuilder.withLongOpt(server) +.hasArg() +.withValueSeparator() +.withDescription(The NLT server address) +.create(s); + +Option numResults = OptionBuilder.withLongOpt(results) +.hasArg() +.withValueSeparator() +.withDescription(Number of results per item) +.create(r); + +Option configFile = OptionBuilder.withLongOpt(config) +.hasArg() +.withValueSeparator() +.withDescription(Use the specified configuration file) +.create(); + +Options mOptions = new Options(); +mOptions.addOption(help); +mOptions.addOption(version); +mOptions.addOption(newRun); +mOptions.addOption(trackerRun); +mOptions.addOption(timeLimit); +mOptions.addOption(age); +mOptions.addOption(server); +mOptions.addOption(numResults); +mOptions.addOption(configFile); + +HelpFormatter formatter = new HelpFormatter(); +final String EOL = System.getProperty(line.separator); +StringWriter out = new StringWriter(); +formatter.printHelp(new PrintWriter(out),80,commandline,header,mOptions,2,2,footer,true); +assertEquals( +usage: commandline [--config arg] [-r arg] [-a arg] [-h] [-t] [-n] [-l+EOL+ + arg] [-s arg] [-v]+EOL+ +header+EOL+ + -a,--age arg Age (in days) of cache item before being recomputed+EOL+ + --config arg Use the specified configuration file+EOL+ + -h,--help print this message+EOL+ + -l,--limit argSet time limit for execution, in mintues+EOL+ + -n,--newCreate NLT cache entries only for new items+EOL+ + -r,--results arg Number of results per item+EOL+ + -s,--server arg The NLT server address+EOL+ + -t,--trackerCreate NLT cache entries only for tracker items+EOL+ + -v,--versionprint version information+EOL+ +footer+EOL +,out.toString
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli Parser.java
roxspring2004/12/27 06:35:36 Modified:cli/src/test/org/apache/commons/cli BugsTest.java cli/src/java/org/apache/commons/cli Parser.java Log: When extracting option values from properties, options with a single argument can now be processed successfully. BR: 31148 Revision ChangesPath 1.21 +18 -0 jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java Index: BugsTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- BugsTest.java 27 Dec 2004 13:33:48 - 1.20 +++ BugsTest.java 27 Dec 2004 14:35:36 - 1.21 @@ -19,6 +19,7 @@ import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Properties; import junit.framework.Test; import junit.framework.TestCase; @@ -478,6 +479,23 @@ -v,--versionprint version information+EOL+ footer+EOL ,out.toString()); +} + +public void test31148() throws ParseException { +Option multiArgOption = new Option(o,option with multiple args); +multiArgOption.setArgs(1); + +Options options = new Options(); +options.addOption(multiArgOption); + +Parser parser = new PosixParser(); +String[] args = new String[]{}; +Properties props = new Properties(); +props.setProperty(o,ovalue); +CommandLine cl = parser.parse(options,args,props); + +assertTrue(cl.hasOption('o')); +assertEquals(ovalue,cl.getOptionValue('o')); } } 1.18 +2 -2 jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java Index: Parser.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- Parser.java 27 Dec 2004 13:21:17 - 1.17 +++ Parser.java 27 Dec 2004 14:35:36 - 1.18 @@ -243,7 +243,7 @@ // get the value from the properties instance String value = properties.getProperty(option); -if (opt.hasArgs()) +if (opt.hasArg()) { if ((opt.getValues() == null) || (opt.getValues().length == 0)) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli HelpFormatter.java
roxspring2004/12/27 06:51:38 Modified:cli/src/test/org/apache/commons/cli BugsTest.java cli/src/java/org/apache/commons/cli HelpFormatter.java Log: Line separator as first char for helpformatter footer and header no longer throws exception BR: 21215 Revision ChangesPath 1.22 +17 -0 jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java Index: BugsTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- BugsTest.java 27 Dec 2004 14:35:36 - 1.21 +++ BugsTest.java 27 Dec 2004 14:51:37 - 1.22 @@ -497,5 +497,22 @@ assertTrue(cl.hasOption('o')); assertEquals(ovalue,cl.getOptionValue('o')); } + +public void test21215() { +Options options = new Options(); +HelpFormatter formatter = new HelpFormatter(); +String SEP = System.getProperty(line.separator); +String header = SEP+Header; +String footer = Footer; +StringWriter out = new StringWriter(); +formatter.printHelp(new PrintWriter(out),80, foobar, header, options, 2, 2, footer, true); +assertEquals( +usage: foobar+SEP+ ++SEP+ +Header+SEP+ ++SEP+ +Footer+SEP +,out.toString()); +} } 1.17 +2 -2 jakarta-commons/cli/src/java/org/apache/commons/cli/HelpFormatter.java Index: HelpFormatter.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/HelpFormatter.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- HelpFormatter.java22 Apr 2004 23:00:09 - 1.16 +++ HelpFormatter.java27 Dec 2004 14:51:38 - 1.17 @@ -797,7 +797,7 @@ if (((pos = text.indexOf('\n', startPos)) != -1 pos = width) || ((pos = text.indexOf('\t', startPos)) != -1 pos = width)) { -return pos; +return pos+1; } else if ((startPos + width) = text.length()) { @@ -872,7 +872,7 @@ int pos = s.length(); -while ((pos = 0) Character.isWhitespace(s.charAt(pos - 1))) +while ((pos 0) Character.isWhitespace(s.charAt(pos - 1))) { --pos; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli BugsTest.java
roxspring2004/12/27 07:25:53 Modified:cli/src/test/org/apache/commons/cli BugsTest.java Log: Added test to demonstrate fix of 19383 BR: 19383 Revision ChangesPath 1.23 +18 -0 jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java Index: BugsTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- BugsTest.java 27 Dec 2004 14:51:37 - 1.22 +++ BugsTest.java 27 Dec 2004 15:25:53 - 1.23 @@ -514,5 +514,23 @@ Footer+SEP ,out.toString()); } + +public void test19383() { +Options options = new Options(); +options.addOption(new Option(a,aaa,false,aaa)); +options.addOption(new Option(null,bbb,false,bbb)); +options.addOption(new Option(c,null,false,ccc)); + +HelpFormatter formatter = new HelpFormatter(); +String SEP = System.getProperty(line.separator); +StringWriter out = new StringWriter(); +formatter.printHelp(new PrintWriter(out),80, foobar, , options, 2, 2, , true); +assertEquals( +usage: foobar [-a] [-c] [--bbb]+SEP+ + -a,--aaa aaa+SEP+ + --bbb bbb+SEP+ + -cccc+SEP +,out.toString()); +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2 DocumentationTest.java
roxspring2004/12/27 09:41:28 Modified:cli/xdocs/examples ant.xml cli/src/test/org/apache/commons/cli2 DocumentationTest.java Log: Documented ant example Revision ChangesPath 1.2 +266 -1jakarta-commons/cli/xdocs/examples/ant.xml Index: ant.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/examples/ant.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ant.xml 2 Sep 2004 13:58:16 - 1.1 +++ ant.xml 27 Dec 2004 17:41:27 - 1.2 @@ -23,12 +23,277 @@ body section name=ant - pTODO what is ant/p + p +This example works through modelling Apache Ant using CLI2, the +example is based on Apache Ant version 1.6.1 compiled on February 12 +2004. + /p + p +Apache Ant is a Java-based build tool. In theory, it is kind of like +Make, but without Make's wrinkles. - For more information please +visit a href=http://ant.apache.org/;http://ant.apache.org//a + /p subsection name=Modelling + p +To model the ant options we first need to create some Builders so that +each of the option instances can be created: + /p +sourcefinal DefaultOptionBuilder obuilder = new DefaultOptionBuilder(); +final ArgumentBuilder abuilder = new ArgumentBuilder(); +final GroupBuilder gbuilder = new GroupBuilder();/source + p + For each option we create an Option instance that will model it, built + using the Builder instances above: + /p +sourceOption help = +obuilder +.withShortName(help) +.withShortName(h) +.withDescription(print this message) +.create(); +Option projecthelp = +obuilder +.withShortName(projecthelp) +.withShortName(p) +.withDescription(print project help information) +.create(); +Option version = +obuilder +.withShortName(version) +.withDescription(print the version information and exit) +.create(); +Option diagnostics = +obuilder +.withShortName(diagnostics) +.withDescription(print information that might be helpful to diagnose or report problems.) +.create(); +Option quiet = +obuilder +.withShortName(quiet) +.withShortName(q) +.withDescription(be extra quiet) +.create(); +Option verbose = +obuilder +.withShortName(verbose) +.withShortName(v) +.withDescription(be extra verbose) +.create(); +Option debug = +obuilder +.withShortName(debug) +.withShortName(d) +.withDescription(print debugging information) +.create(); +Option emacs = +obuilder +.withShortName(emacs) +.withShortName(e) +.withDescription(produce logging information without adornments) +.create(); +Option lib = +obuilder +.withShortName(lib) +.withDescription(specifies a path to search for jars and classes) +.withArgument( +abuilder +.withName(path) +.withMinimum(1) +.withMaximum(1) +.create()) +.create(); +Option logfile = +obuilder +.withShortName(logfile) +.withShortName(l) +.withDescription(use given file for log) +.withArgument( +abuilder +.withName(file) +.withMinimum(1) +.withMaximum(1) +.create()) +.create(); +Option logger = +obuilder +.withShortName(logger) +.withDescription(the class which is to perform logging) +.withArgument( +abuilder +.withName(classname) +.withMinimum(1) +.withMaximum(1) +.create()) +.create(); +Option listener = +obuilder +.withShortName(listener) +.withDescription(add an instance of class as a project listener) +.withArgument( +abuilder +.withName(classname) +.withMinimum(1) +.withMaximum(1) +.create()) +.create(); +Option noinput = +obuilder +.withShortName(noinput) +.withDescription(do not allow interactive input) +.create(); +Option buildfile = +obuilder +.withShortName(buildfile) +.withShortName(file) +.withShortName(f) +.withDescription(use given buildfile) +.withArgument( +abuilder +.withName(file
cvs commit: jakarta-commons/cli/xdocs/examples index.xml
roxspring2004/12/27 10:17:06 Modified:cli/xdocs/examples index.xml Log: Added examples overview documentation Revision ChangesPath 1.2 +14 -1 jakarta-commons/cli/xdocs/examples/index.xml Index: index.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/examples/index.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- index.xml 2 Sep 2004 13:58:16 - 1.1 +++ index.xml 27 Dec 2004 18:17:06 - 1.2 @@ -23,7 +23,20 @@ body section name=Overview - pTODO quick overview to the examples/p + p +The examples section aims to show how a variety of applications and +tools could be modelled using CLI2. We make no claim that these tools +use CLI2 in their implementation but simply use their interfaces to +demonstrate commonly needed features. Some examples will make +simplifications to keep the documentation consise. + /p + p +Many aspects of the API are touched upon but few are described in +great detail. If more information is required then the reader is +encouraged to review the API documentation and look at the unit tests +for inspiration. Failing that, further advice and discussion can be +found on the codecommons-user@jakarta.apache.org/code mailing list. + /p /section /body /document - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli project.properties
roxspring2004/12/27 14:22:02 Modified:cli project.properties Log: Force 1.3 compatibility even when compiling under 5.0 Revision ChangesPath 1.12 +5 -0 jakarta-commons/cli/project.properties Index: project.properties === RCS file: /home/cvs/jakarta-commons/cli/project.properties,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- project.properties2 Sep 2004 13:57:06 - 1.11 +++ project.properties27 Dec 2004 22:22:02 - 1.12 @@ -6,6 +6,9 @@ compile.optimize = off compile.deprecation = off +maven.compile.source=1.3 +maven.compile.target=1.3 + maven.jarResources.basedir=${basedir}/src/java # Reset the checkstyle properties to use the default sun settings @@ -24,3 +27,5 @@ maven.jar.manifest=${basedir}/src/conf/MANIFEST.MF maven.pdf.navigationFile=navigation-pdf.xml + +maven.svg.executeOnload=true - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2/application CpTest.java
roxspring2004/12/23 07:04:40 Modified:cli/src/test/org/apache/commons/cli2/util HelpFormatterTest.java cli/src/test/org/apache/commons/cli2/application CpTest.java Log: Brought CpTest inline with new default display settings Testtime console output back to none Revision ChangesPath 1.4 +0 -1 jakarta-commons/cli/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java Index: HelpFormatterTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- HelpFormatterTest.java14 Oct 2004 22:50:31 - 1.3 +++ HelpFormatterTest.java23 Dec 2004 15:04:40 - 1.4 @@ -199,7 +199,6 @@ helpFormatter.setGroup(options); helpFormatter.setPrintWriter(new PrintWriter(writer)); helpFormatter.printHelp(); -System.out.println(writer); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); assertEquals( 1.3 +21 -21 jakarta-commons/cli/src/test/org/apache/commons/cli2/application/CpTest.java Index: CpTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/application/CpTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CpTest.java 22 Apr 2004 23:00:13 - 1.2 +++ CpTest.java 23 Dec 2004 15:04:40 - 1.3 @@ -397,67 +397,67 @@ OPTIONS , in.readLine()); assertEquals( - -a (--archive)same as -dpR , + -a (--archive)same as -dpR , in.readLine()); assertEquals( - -b (--backup) make backup before removal , + -b (--backup) make backup before removal , in.readLine()); assertEquals( - -d (--no-dereference) preserve links , + -d (--no-dereference) preserve links , in.readLine()); assertEquals( - -f (--force) remove existing destinations, never prompt , + -f (--force) remove existing destinations, never prompt , in.readLine()); assertEquals( - -i (--interactive)prompt before overwrite , + -i (--interactive)prompt before overwrite , in.readLine()); assertEquals( - -l (--link) link files instead of copying , + -l (--link) link files instead of copying , in.readLine()); assertEquals( - -p (--preserve) preserve file attributes if possible, + -p (--preserve) preserve file attributes if possible, in.readLine()); assertEquals( - -P (--parents)append source path to DIRECTORY , + -P (--parents)append source path to DIRECTORY , in.readLine()); assertEquals( - -rcopy recursively, non-directories as files , + -rcopy recursively, non-directories as files , in.readLine()); assertEquals( - --sparse control creation of sparse files , + --sparse WHEN control creation of sparse files, in.readLine()); assertEquals( - -R (--recursive) copy directories recursively , + -R (--recursive) copy directories recursively , in.readLine()); assertEquals( - -s (--symbolic-link) make symbolic links instead of copying , + -s (--symbolic-link) make symbolic links instead of copying , in.readLine()); assertEquals( - -S (--suffix) override the usual backup
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/util HelpFormatter.java
roxspring2004/10/14 15:50:32 Modified:cli/src/test/org/apache/commons/cli2/util HelpFormatterTest.java cli/src/java/org/apache/commons/cli2/util HelpFormatter.java Log: HelpFormatter now applys a minimum description width of 1 character Revision ChangesPath 1.3 +57 -17 jakarta-commons/cli/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java Index: HelpFormatterTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HelpFormatterTest.java22 Apr 2004 23:00:15 - 1.2 +++ HelpFormatterTest.java14 Oct 2004 22:50:31 - 1.3 @@ -24,6 +24,7 @@ import junit.framework.TestCase; +import org.apache.commons.cli2.Group; import org.apache.commons.cli2.Option; import org.apache.commons.cli2.OptionException; import org.apache.commons.cli2.builder.DefaultOptionBuilder; @@ -34,6 +35,7 @@ public class HelpFormatterTest extends TestCase { private HelpFormatter helpFormatter; private Option verbose; +private Group options; public void setUp() { helpFormatter = new HelpFormatter(|*, *-*, *|, 80); @@ -49,23 +51,24 @@ .withDescription(print the version information and exit) .create(); -helpFormatter.setGroup( -new GroupBuilder() -.withName(options) -.withOption(DefaultOptionTest.buildHelpOption()) -.withOption(ArgumentTest.buildTargetsArgument()) -.withOption( -new DefaultOptionBuilder() -.withLongName(diagnostics) -.withDescription(print information that might be helpful to diagnose or report problems.) -.create()) -.withOption( -new DefaultOptionBuilder() -.withLongName(projecthelp) -.withDescription(print project help information) -.create()) -.withOption(verbose) -.create()); +options = new GroupBuilder() +.withName(options) +.withOption(DefaultOptionTest.buildHelpOption()) +.withOption(ArgumentTest.buildTargetsArgument()) +.withOption( +new DefaultOptionBuilder() +.withLongName(diagnostics) +.withDescription(print information that might be helpful to diagnose or report problems.) +.create()) +.withOption( +new DefaultOptionBuilder() +.withLongName(projecthelp) +.withDescription(print project help information) +.create()) +.withOption(verbose) +.create(); + +helpFormatter.setGroup(options); } public void testPrint() throws IOException { @@ -190,6 +193,27 @@ assertNull(reader.readLine()); } +public void testPrintHelp_TooNarrow() throws IOException { +final StringWriter writer = new StringWriter(); +helpFormatter = new HelpFormatter(,=,,4); +helpFormatter.setGroup(options); +helpFormatter.setPrintWriter(new PrintWriter(writer)); +helpFormatter.printHelp(); +System.out.println(writer); +final BufferedReader reader = +new BufferedReader(new StringReader(writer.toString())); +assertEquals( +options = , +reader.readLine()); +assertEquals( + --help (-?,-h) =D, +reader.readLine()); +assertEquals( + =i, +reader.readLine()); +// lots more lines unchecked +} + public void testPrintException() throws IOException { final StringWriter writer = new StringWriter(); helpFormatter.setPrintWriter(new PrintWriter(writer)); @@ -322,6 +346,16 @@ assertEquals(, i.next()); assertFalse(i.hasNext()); } + +public void testWrap_Below1Length() { +try{ +HelpFormatter.wrap(Apache Software Foundation,-1); +fail(IllegalArgumentException); +} +catch(IllegalArgumentException e) { +assertEquals(width must be positive,e.getMessage()); +} +} public void testPad() throws IOException { final StringWriter writer = new StringWriter(); @@ -338,6 +372,12 @@ public void testPad_TooLong() throws IOException
cvs commit: jakarta-commons/cli/xdocs index.xml
roxspring2004/10/13 15:38:54 Modified:cli/xdocs index.xml Log: Added dependancies note to front page Revision ChangesPath 1.5 +35 -1 jakarta-commons/cli/xdocs/index.xml Index: index.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/index.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- index.xml 5 Oct 2004 23:26:33 - 1.4 +++ index.xml 13 Oct 2004 22:38:54 - 1.5 @@ -46,7 +46,7 @@ expected. /p p -The rest of the documentation is split into the followin three sections: +The rest of the documentation is split into the following three sections: ul lia href=manual/index.htmlCLI2/a - a reference manual for version 2/li lia href=introduction.htmlCLI1/a - documentation for version 1 /li @@ -64,6 +64,40 @@ /ul /p /section +section name=Dependancies + p +The generated list of a href=dependencies.htmldependencies/a +lists the libraries needed to compile and test Commons CLI. To use +the precompiled distribution none of these dependancies are strictly +necessary. The following is a breakdown of what is required and when: + /p + table +tr + thLibrary/ththUsage/th +/tr +tr + tdJava 1.2/td + tdThis is the minimum java level needed to use CLI2/td +/tr +tr + tdJava 1.4/td + tdNeeded if the PreferencesCommandLine is needed/td +/tr +tr + tdcommons-lang/td + tdNeeded if the CLI1 package is being used/td +/tr +tr + tdjdepend/td + tdNeeded to build and test CLI2 only/td +/tr +tr + tdjunit/td + tdNeeded to build and test CLI1 and CLI2/td +/tr + /table +/section + /body /document - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/option OptionImpl.java
roxspring2004/10/08 03:22:07 Modified:cli/src/java/org/apache/commons/cli2/option OptionImpl.java Log: OptionImpl now avoids NullPointerExceptions Revision ChangesPath 1.5 +17 -6 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/OptionImpl.java Index: OptionImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/OptionImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- OptionImpl.java 7 Sep 2004 00:18:23 - 1.4 +++ OptionImpl.java 8 Oct 2004 10:22:07 - 1.5 @@ -69,18 +69,29 @@ final OptionImpl that = (OptionImpl)thatObj; return getId() == that.getId() - getPreferredName().equals(that.getPreferredName()) - (getDescription() == that.getDescription() -|| getDescription().equals(that.getDescription())) - getPrefixes().equals(that.getPrefixes()) - getTriggers().equals(that.getTriggers()); + equals(getPreferredName(),that.getPreferredName()) + equals(getDescription(),that.getDescription()) + equals(getPrefixes(),that.getPrefixes()) + equals(getTriggers(),that.getTriggers()); } else { return false; } } -public int hashCode() { + private boolean equals(Object left, Object right) { + if(left==null right==null){ + return true; + } + else if(left==null || right==null){ + return false; + } + else{ + return left.equals(right); + } + } + + public int hashCode() { int hashCode = getId(); hashCode = hashCode * 37 + getPreferredName().hashCode(); if (getDescription() != null) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/option GroupImpl.java
roxspring2004/10/08 03:23:11 Modified:cli/src/java/org/apache/commons/cli2/option GroupImpl.java Log: GroupImpl.validate() always validates instances of Group since they may contain other options that need validating Revision ChangesPath 1.6 +3 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/GroupImpl.java Index: GroupImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/GroupImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- GroupImpl.java2 Oct 2004 13:16:21 - 1.5 +++ GroupImpl.java8 Oct 2004 10:23:11 - 1.6 @@ -227,6 +227,9 @@ if(option.isRequired()){ option.validate(commandLine); } +if(option instanceof Group){ + option.validate(commandLine); +} // if the child option is present then validate it if (commandLine.hasOption(option)) { if (++present maximum) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/builder PatternBuilder.java DefaultOptionBuilder.java CommandBuilder.java GroupBuilder.java ArgumentBuilder.java SwitchBuilder.java
roxspring2004/10/08 09:35:34 Modified:cli/src/java/org/apache/commons/cli2/builder PatternBuilder.java DefaultOptionBuilder.java CommandBuilder.java GroupBuilder.java ArgumentBuilder.java SwitchBuilder.java Log: *Builder.reset() now returns this builder instance Revision ChangesPath 1.3 +2 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/PatternBuilder.java Index: PatternBuilder.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/PatternBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PatternBuilder.java 22 Apr 2004 23:00:15 - 1.2 +++ PatternBuilder.java 8 Oct 2004 16:35:34 - 1.3 @@ -91,8 +91,9 @@ /** * Resets this builder */ -public void reset() { +public PatternBuilder reset() { options.clear(); +return this; } private void createOption( 1.4 +2 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/DefaultOptionBuilder.java Index: DefaultOptionBuilder.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/DefaultOptionBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DefaultOptionBuilder.java 7 Sep 2004 00:18:24 - 1.3 +++ DefaultOptionBuilder.java 8 Oct 2004 16:35:34 - 1.4 @@ -116,7 +116,7 @@ /** * Resets the builder */ -public void reset() { +public DefaultOptionBuilder reset() { preferredName = null; description = null; aliases = new HashSet(); @@ -125,6 +125,7 @@ argument = null; children = null; id = 0; +return this; } /** 1.3 +2 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/CommandBuilder.java Index: CommandBuilder.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/CommandBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CommandBuilder.java 22 Apr 2004 23:00:15 - 1.2 +++ CommandBuilder.java 8 Oct 2004 16:35:34 - 1.3 @@ -76,7 +76,7 @@ * Resets the CommandBuilder to the defaults for a new Command. The method * should be called automatically at the end of a create() call. */ -public void reset() { +public CommandBuilder reset() { preferredName = null; description = null; aliases = new HashSet(); @@ -84,6 +84,7 @@ argument = null; children = null; id = 0; +return this; } /** 1.3 +2 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/GroupBuilder.java Index: GroupBuilder.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/GroupBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GroupBuilder.java 22 Apr 2004 23:00:15 - 1.2 +++ GroupBuilder.java 8 Oct 2004 16:35:34 - 1.3 @@ -56,12 +56,13 @@ /** * Resets the builder */ -public void reset() { +public GroupBuilder reset() { name = null; description = null; options = new ArrayList(); minimum = 0; maximum = Integer.MAX_VALUE; +return this; } /** 1.4 +2 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/ArgumentBuilder.java Index: ArgumentBuilder.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/ArgumentBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ArgumentBuilder.java 2 Oct 2004 11:35:34 - 1.3 +++ ArgumentBuilder.java 8 Oct 2004 16:35:34 - 1.4 @@ -93,7 +93,7 @@ * Resets the ArgumentBuilder to the defaults for a new Argument. The * method should be called automatically at the end of a create() call. */ -public final void reset() { +public final ArgumentBuilder reset() { name = arg; description = null; minimum = 0; @@ -104,6 +104,7 @@ consumeRemaining = --; defaultValues = null; id = 0; +return
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/option PropertyOption.java
roxspring2004/10/08 12:41:19 Modified:cli/src/java/org/apache/commons/cli2/option PropertyOption.java Log: Made default constants public Revision ChangesPath 1.3 +2 -2 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/PropertyOption.java Index: PropertyOption.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/PropertyOption.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PropertyOption.java 22 Apr 2004 23:00:07 - 1.2 +++ PropertyOption.java 8 Oct 2004 19:41:18 - 1.3 @@ -31,8 +31,8 @@ */ public class PropertyOption extends OptionImpl { -private static final String DEFAULT_OPTION_STRING = -D; -private static final String DEFAULT_DESCRIPTION = +public static final String DEFAULT_OPTION_STRING = -D; +public static final String DEFAULT_DESCRIPTION = Passes properties and values to the application; private final String optionString; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/option DefaultOption.java Switch.java Command.java
roxspring2004/10/08 15:52:53 Modified:cli/src/java/org/apache/commons/cli2 messages.properties cli/src/java/org/apache/commons/cli2/option DefaultOption.java Switch.java Command.java Log: Added missing required option message Revision ChangesPath 1.3 +1 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/messages.properties Index: messages.properties === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/messages.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- messages.properties 22 Apr 2004 23:00:06 - 1.2 +++ messages.properties 8 Oct 2004 22:52:53 - 1.3 @@ -4,3 +4,4 @@ cli.error.missing.option = Missing option cli.error.burst = Could not burst {0} while processing cli.error.badproperty = Could not understand property: {0} +cli.error.missing.required = Missing required option 1.4 +1 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/DefaultOption.java Index: DefaultOption.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/DefaultOption.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DefaultOption.java7 Sep 2004 00:18:23 - 1.3 +++ DefaultOption.java8 Oct 2004 22:52:53 - 1.4 @@ -184,7 +184,7 @@ public void validate(WriteableCommandLine commandLine) throws OptionException { if (isRequired() !commandLine.hasOption(this)) { -throw new OptionException(this); +throw new OptionException(this,cli.error.missing.required, getPreferredName()); } super.validate(commandLine); 1.6 +1 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Switch.java Index: Switch.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Switch.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Switch.java 2 Oct 2004 13:16:21 - 1.5 +++ Switch.java 8 Oct 2004 22:52:53 - 1.6 @@ -165,7 +165,7 @@ public void validate(WriteableCommandLine commandLine) throws OptionException { if (isRequired() !commandLine.hasOption(this)) { -throw new OptionException(this); +throw new OptionException(this,cli.error.missing.required, getPreferredName()); } super.validate(commandLine); 1.3 +1 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Command.java Index: Command.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Command.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Command.java 22 Apr 2004 23:00:07 - 1.2 +++ Command.java 8 Oct 2004 22:52:53 - 1.3 @@ -129,7 +129,7 @@ public void validate(WriteableCommandLine commandLine) throws OptionException { if (isRequired() !commandLine.hasOption(this)) { -throw new OptionException(this); +throw new OptionException(this,cli.error.missing.required, getPreferredName()); } super.validate(commandLine); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/manual builders.xml
roxspring2004/10/05 16:09:38 Modified:cli/xdocs/manual builders.xml Log: Added todo and removed image placeholder Revision ChangesPath 1.2 +1 -1 jakarta-commons/cli/xdocs/manual/builders.xml Index: builders.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/manual/builders.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- builders.xml 2 Sep 2004 13:58:02 - 1.1 +++ builders.xml 5 Oct 2004 23:09:38 - 1.2 @@ -23,7 +23,7 @@ body section name=Builders - img src=../images/builders.jpg/ + pTODO describe builders and resaons for their use/p subsection name=GroupBuilder /subsection subsection name=ArgumentBuilder - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/manual options.xml
roxspring2004/10/05 16:10:31 Modified:cli/xdocs/manual options.xml Log: Documented the various options and their properties Revision ChangesPath 1.2 +330 -0jakarta-commons/cli/xdocs/manual/options.xml Index: options.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/manual/options.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- options.xml 2 Sep 2004 13:58:02 - 1.1 +++ options.xml 5 Oct 2004 23:10:31 - 1.2 @@ -25,22 +25,352 @@ section name=Options img src=../images/options.jpg/ subsection name=Option + p +In CLI2 every element of the command line interface is modelled as an +Option instance, and has the following readonly properties that are +inherited by all other Option implementations: + /p + table +tr + thProperty/ththType/ththDescription/th +/tr +tr + tdid/td + tdint/td + td +Some people find it useful to give each option a unique identifer +so that they can use the options within a java codeswitch/code +statement. This value is entirely optional and it is up to the +user to ensure any uniqueness. + /td +/tr +tr + tdpreferredName/td + tdString/td + td +Every option has a preferred name that can be used for the minimal +codetoString()/code implementation. Options can usually have +many additional names too. + /td +/tr +tr + tdrequired/td + tdboolean/td + td +True here indicates that the command line is invalid if this +option doesn't appear on it. + /td +/tr + /table /subsection + subsection name=Group + source-a|-b|-c|-d|-e/source + p +Groups are possible the least intuitive form of Option since they +actually represent a collection of other options. Most member Options +can appear on a command line in any order with the exception of +Arguments; they must appear in the given order as there is no other +way to identify one from another. An additional restriction of the +standard Group implementation is that only the final argument can have +variable size (differing minimum and maximum). + /p + p +Groups inherit all the properties of Options. + /p + table +tr + thProperty/ththType/ththDescription/th +/tr +tr + tdminimum/td + tdint/td + td +The minimum number of member options that must be present on the +command line for this group to be valid. Typically this will +either be 0 where the group is optional or 1 to indicate at least +one of them is needed. This value does not count anonymous +options. + /td +/tr +tr + tdmaximum/td + tdint/td + td +The maximum number of options from this Group that can appear in a +command line. This would typically be used if you wanted to +create an exclusive group where a maximum of 1 member is allowed +to appear. This value does not count anonymous options. + /td +/tr + /table /subsection + subsection name=Argument + sourcelt;arg1gt; [lt;arg2gt; ...]/source + p +Arguments are used to pass in values from the command line, for +example to pass in a list of files to be operated on. Arguments can +appear in two different situations within an option model, the most +frequently used situation is where the value found should be associated +with a Parent option; in this situation the value is expected to +immediately follow the Parent in the command line. The second +scenario where Arguments are used is when they are added to a Group +directly rather than being composed with a Parent first. These +'anonymous' arguments have nothing that identifies them on the +command line other than the order in which they appear. + /p + p +Multiple values may be parsed by a single argument and the minimum +and maximum attributes can used to control their validity, +additionally a Validator may be used to identify whether individual +values are valid. In some situations it can be useful to parse the +supplied
cvs commit: jakarta-commons/cli/xdocs index.xml
roxspring2004/10/05 16:26:33 Modified:cli/xdocs index.xml Log: Added links to latest website and pdf Revision ChangesPath 1.4 +10 -0 jakarta-commons/cli/xdocs/index.xml Index: index.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/index.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- index.xml 2 Sep 2004 17:26:22 - 1.3 +++ index.xml 5 Oct 2004 23:26:33 - 1.4 @@ -53,6 +53,16 @@ lia href=examples/index.htmlExamples/a - a selection of worked examples demonstrating CLI2 features/li /ul /p + p +The latest version of this documentation is available on the web: +ul + lia href=http://jakarta.apache.org/commons/cli/;http://jakarta.apache.org/commons/cli//a/li + li +a href=http://jakarta.apache.org/commons/cli/commons-cli.pdf;http://jakarta.apache.org/commons/cli/commons-cli.pdf/a +a href=http://jakarta.apache.org/commons/cli/commons-cli.pdf;img border=0 src=images/pdf.gif//a + /li +/ul + /p /section /body - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/conf MANIFEST.MF
roxspring2004/10/05 17:33:38 Modified:cli/src/conf MANIFEST.MF Log: Final manifest now works correctly with java package versioning Revision ChangesPath 1.4 +4 -8 jakarta-commons/cli/src/conf/MANIFEST.MF Index: MANIFEST.MF === RCS file: /home/cvs/jakarta-commons/cli/src/conf/MANIFEST.MF,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MANIFEST.MF 18 Aug 2004 00:44:47 - 1.3 +++ MANIFEST.MF 6 Oct 2004 00:33:37 - 1.4 @@ -1,15 +1,11 @@ -Name: org/apache/commons/cli +Implementation-Title: Jakarta Commons CLI2 + +Name: org/apache/commons/cli/ Specification-Title: Jakarta Commons CLI Specification-Vendor: Apache Software Foundation Specification-Version: 1.0 -Implementation-Title: org.apache.commons.cli -Implementation-Vendor: Apache Software Foundation -Implementation-Version: 2.0 -Name: org/apache/commons/cli2 +Name: org/apache/commons/cli2/ Specification-Title: Jakarta Commons CLI2 Specification-Vendor: Apache Software Foundation Specification-Version: 2.0 -Implementation-Title: org.apache.commons.cli2 -Implementation-Vendor: Apache Software Foundation -Implementation-Version: 2.0 \ No newline at end of file - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2/option ArgumentTest.java
roxspring2004/10/02 04:35:34 Modified:cli/src/java/org/apache/commons/cli2/builder ArgumentBuilder.java cli/src/test/org/apache/commons/cli2/option ArgumentTest.java Log: ArgumentBuilder now resets the validator to null on reset() Revision ChangesPath 1.3 +1 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/ArgumentBuilder.java Index: ArgumentBuilder.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/builder/ArgumentBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ArgumentBuilder.java 22 Apr 2004 23:00:15 - 1.2 +++ ArgumentBuilder.java 2 Oct 2004 11:35:34 - 1.3 @@ -100,6 +100,7 @@ maximum = Integer.MAX_VALUE; initialSeparator = ArgumentImpl.DEFAULT_INITIAL_SEPARATOR; subsequentSeparator = ArgumentImpl.DEFAULT_SUBSEQUENT_SEPARATOR; +validator = null; consumeRemaining = --; defaultValues = null; id = 0; 1.3 +2 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/option/ArgumentTest.java Index: ArgumentTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/option/ArgumentTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ArgumentTest.java 22 Apr 2004 23:00:14 - 1.2 +++ ArgumentTest.java 2 Oct 2004 11:35:34 - 1.3 @@ -319,6 +319,7 @@ final ListIterator iterator = args.listIterator(); try { option.processValues(commandLine, iterator, option); +option.validate(commandLine); fail(Expected MissingValueException); } catch (OptionException mve) { @@ -549,6 +550,7 @@ try { option.process(commandLine, iterator); +option.validate(commandLine); fail(Missing Value!); } catch (OptionException mve) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2 CommandLineTestCase.java
roxspring2004/10/02 06:16:21 Modified:cli/src/java/org/apache/commons/cli2/option GroupImpl.java Switch.java cli/src/test/org/apache/commons/cli2/option GroupTest.java cli/src/test/org/apache/commons/cli2 CommandLineTestCase.java Log: GroupImpl now respects the required attribute of the child options (bug identified by Andrew Ferguson) Switch only adds the option to the commandline once. Revision ChangesPath 1.5 +5 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/GroupImpl.java Index: GroupImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/GroupImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- GroupImpl.java6 Sep 2004 22:57:44 - 1.4 +++ GroupImpl.java2 Oct 2004 13:16:21 - 1.5 @@ -223,6 +223,11 @@ for (final Iterator i = options.iterator(); i.hasNext();) { final Option option = (Option) i.next(); +// if the child option is required then validate it +if(option.isRequired()){ +option.validate(commandLine); +} +// if the child option is present then validate it if (commandLine.hasOption(option)) { if (++present maximum) { unexpected = option; 1.5 +0 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Switch.java Index: Switch.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Switch.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Switch.java 7 Sep 2004 00:18:23 - 1.4 +++ Switch.java 2 Oct 2004 13:16:21 - 1.5 @@ -140,7 +140,6 @@ final String arg = (String)arguments.next(); if (canProcess(arg)) { -commandLine.addOption(this); if (arg.startsWith(enabledPrefix)) { commandLine.addSwitch(this, true); arguments.set(enabledPrefix + preferredName); 1.3 +38 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/option/GroupTest.java Index: GroupTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/option/GroupTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GroupTest.java22 Apr 2004 23:00:14 - 1.2 +++ GroupTest.java2 Oct 2004 13:16:21 - 1.3 @@ -28,6 +28,8 @@ import org.apache.commons.cli2.Option; import org.apache.commons.cli2.OptionException; import org.apache.commons.cli2.WriteableCommandLine; +import org.apache.commons.cli2.builder.DefaultOptionBuilder; +import org.apache.commons.cli2.builder.GroupBuilder; /** * @author Rob Oxspring @@ -245,6 +247,42 @@ catch (OptionException moe) { assertEquals(option, moe.getOption()); } +} + +public void testValidate_RequiredChild() throws OptionException { +final Option required = new DefaultOptionBuilder().withLongName(required).withRequired(true).create(); +final Option optional = new DefaultOptionBuilder().withLongName(optional).withRequired(false).create(); +final Group group = new GroupBuilder() +.withOption(required) +.withOption(optional) +.withMinimum(1) +.create(); + +WriteableCommandLine commandLine; + +commandLine = commandLine(group, list()); +try { +group.validate(commandLine); +fail(Missing option 'required'); +} +catch (OptionException moe) { +assertEquals(required, moe.getOption()); +} + +commandLine = commandLine(group, list()); +commandLine.addOption(optional); +try { +group.validate(commandLine); +fail(Missing option 'required'); +} +catch (OptionException moe) { +assertEquals(required, moe.getOption()); +} + +commandLine = commandLine(group, list()); +commandLine.addOption(required); +group.validate(commandLine); + } /* 1.3 +4 -2 jakarta-commons/cli/src/test/org/apache/commons/cli2/CommandLineTestCase.java Index: CommandLineTestCase.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/option ArgumentImpl.java
roxspring2004/09/09 04:39:15 Modified:cli/src/java/org/apache/commons/cli2/option ArgumentImpl.java Log: ArgumentImpl now deals with defaults a little better Revision ChangesPath 1.4 +1 -6 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/ArgumentImpl.java Index: ArgumentImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/ArgumentImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ArgumentImpl.java 6 Sep 2004 22:57:44 - 1.3 +++ ArgumentImpl.java 9 Sep 2004 11:39:15 - 1.4 @@ -146,7 +146,7 @@ final ListIterator arguments, final Option option) throws OptionException { -int argumentCount = commandLine.getValues(option).size(); +int argumentCount = commandLine.getValues(option,Collections.EMPTY_LIST).size(); final int initialCount = argumentCount; while (arguments.hasNext() argumentCount maximum) { @@ -193,11 +193,6 @@ ++argumentCount; commandLine.addValue(option, allValues); } -} - -if (this.defaultValues == null - (argumentCount minimum || initialCount == argumentCount)) { -throw new OptionException(option, cli.error.missing.values); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli BugsTest.java
roxspring2004/09/06 15:51:45 Modified:cli/src/test/org/apache/commons/cli BugsTest.java Log: Test checks the displayed output and does so quietly Revision ChangesPath 1.19 +27 -5 jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java Index: BugsTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- BugsTest.java 22 Apr 2004 23:00:07 - 1.18 +++ BugsTest.java 6 Sep 2004 22:51:45 - 1.19 @@ -15,6 +15,10 @@ */ package org.apache.commons.cli; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.io.StringWriter; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -274,12 +278,30 @@ .hasArg() .create( 'd' ); options.addOption( dir ); -try { -HelpFormatter formatter = new HelpFormatter(); -formatter.printHelp( dir, options ); + + +final PrintStream oldSystemOut = System.out; +try{ +final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); +final PrintStream print = new PrintStream(bytes); + +// capture this platform's eol symbol +print.println(); +final String eol = bytes.toString(); +bytes.reset(); + +System.setOut(new PrintStream(bytes)); +try { +HelpFormatter formatter = new HelpFormatter(); +formatter.printHelp( dir, options ); +} +catch( Exception exp ) { +fail( Unexpected Exception: + exp.getMessage() ); +} +assertEquals(usage: dir+eol+ -d arg dir+eol,bytes.toString()); } -catch( Exception exp ) { -fail( Unexpected Exception: + exp.getMessage() ); +finally { +System.setOut(oldSystemOut); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/builder SwitchBuilder.java
roxspring2004/09/06 15:57:44 Modified:cli/src/java/org/apache/commons/cli2 Argument.java Option.java WriteableCommandLine.java cli/src/java/org/apache/commons/cli2/option GroupImpl.java Switch.java ParentImpl.java OptionImpl.java ArgumentImpl.java cli/src/java/org/apache/commons/cli2/commandline Parser.java WriteableCommandLineImpl.java cli/src/test/org/apache/commons/cli2/option SwitchTest.java cli/src/java/org/apache/commons/cli2/builder SwitchBuilder.java Log: Implemented definition time defaults: Option - added defaults(WriteableCommandLine) WriteableCommandLine - added setDefaultValues(Option,List) WriteableCommandLine - added setDefaultSwitch(Option,Boolean) Argument - add defaults(WriteableCommandLine,Option) CommandLineDefaultsTest - test the defaults in combination Parser - now applys the defaults before processing Implemented new methods Revision ChangesPath 1.3 +10 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/Argument.java Index: Argument.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Argument.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Argument.java 22 Apr 2004 23:00:06 - 1.2 +++ Argument.java 6 Sep 2004 22:57:43 - 1.3 @@ -49,6 +49,16 @@ final ListIterator args, final Option option) throws OptionException; + +/** + * Adds defaults to a CommandLine. + * + * @param commandLine + *The CommandLine object to store defaults in. + * @param option + *The Option to store the defaults against. + */ +void defaultValues(final WriteableCommandLine commandLine, final Option option); /** * Performs any necessary validation on the values added to the 1.3 +11 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/Option.java Index: Option.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Option.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Option.java 22 Apr 2004 23:00:06 - 1.2 +++ Option.java 6 Sep 2004 22:57:43 - 1.3 @@ -47,6 +47,17 @@ final WriteableCommandLine commandLine, final ListIterator args) throws OptionException; + +/** + * Adds defaults to a CommandLine. + * + * Any defaults for this option are applied as well as the defaults for + * any contained options + * + * @param commandLine + *The CommandLine object to store defaults in + */ +void defaults(final WriteableCommandLine commandLine); /** * Indicates whether this Option will be able to process the particular 1.3 +16 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/WriteableCommandLine.java Index: WriteableCommandLine.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/WriteableCommandLine.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WriteableCommandLine.java 22 Apr 2004 23:00:06 - 1.2 +++ WriteableCommandLine.java 6 Sep 2004 22:57:43 - 1.3 @@ -15,6 +15,8 @@ */ package org.apache.commons.cli2; +import java.util.List; + /** * A CommandLine that detected values and options can be written to. */ @@ -32,6 +34,13 @@ * @param value the value to add */ void addValue(final Option option, final Object value); + +/** + * Sets the default values for an Option in the CommandLine + * @param option the Option to add to + * @param defaultValues the defaults for the option + */ +void setDefaultValues(final Option option, final List defaultValues); /** * Adds a switch value to an Option in the CommandLine. @@ -40,6 +49,13 @@ * @throws IllegalStateException if the switch has already been added */ void addSwitch(final Option option, final boolean value) throws IllegalStateException; + +/** + * Sets the default state for a Switch in the CommandLine. + * @param option the Option to add to + * @param defaultSwitch the defaults state for ths switch + */ +void setDefaultSwitch(final Option option, final Boolean defaultSwitch); /** * Adds a property value to a name in the CommandLine
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2 CommandLineDefaultsTest.java
roxspring2004/09/06 15:58:06 Added: cli/src/test/org/apache/commons/cli2 CommandLineDefaultsTest.java Log: Implemented definition time defaults: Option - added defaults(WriteableCommandLine) WriteableCommandLine - added setDefaultValues(Option,List) WriteableCommandLine - added setDefaultSwitch(Option,Boolean) Argument - add defaults(WriteableCommandLine,Option) CommandLineDefaultsTest - test the defaults in combination Parser - now applys the defaults before processing Implemented new methods Revision ChangesPath 1.2 +250 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/CommandLineDefaultsTest.java - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/builder DefaultOptionBuilder.java SwitchBuilder.java
roxspring2004/09/06 17:18:24 Modified:cli/src/java/org/apache/commons/cli2/option DefaultOption.java Switch.java messages.properties OptionImpl.java cli/src/java/org/apache/commons/cli2/builder DefaultOptionBuilder.java SwitchBuilder.java Log: Added checks and documentation to ensure preferredName and any aliases begin with a specified prefix Bug: 30979 Revision ChangesPath 1.3 +5 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/DefaultOption.java Index: DefaultOption.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/DefaultOption.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultOption.java22 Apr 2004 23:00:07 - 1.2 +++ DefaultOption.java7 Sep 2004 00:18:23 - 1.3 @@ -67,7 +67,7 @@ * @param shortPrefix the prefix used for short options * @param longPrefix the prefix used for long options * @param burstEnabled should option bursting be enabled - * @param preferredName the preferred name for this Option + * @param preferredName the preferred name for this Option, this should begin with either shortPrefix or longPrefix * @param description a description of this Option * @param aliases the alternative names for this Option * @param burstAliases the aliases that can be burst @@ -75,6 +75,8 @@ * @param argument the Argument belonging to this Parent, or null * @param children the Group children belonging to this Parent, ot null * @param id the unique identifier for this Option + * @throws IllegalArgumentException if the preferredName or an alias isn't + * prefixed with shortPrefix or longPrefix */ public DefaultOption( final String shortPrefix, @@ -121,6 +123,8 @@ newPrefixes.add(shortPrefix); newPrefixes.add(longPrefix); this.prefixes = Collections.unmodifiableSet(newPrefixes); + +checkPrefixes(newPrefixes); } public boolean canProcess(final String argument) { 1.4 +4 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Switch.java Index: Switch.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Switch.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Switch.java 6 Sep 2004 22:57:44 - 1.3 +++ Switch.java 7 Sep 2004 00:18:23 - 1.4 @@ -65,6 +65,8 @@ * @param argument the Argument belonging to this Parent, or null * @param children the Group children belonging to this Parent, ot null * @param id the unique identifier for this Option + * @throws IllegalArgumentException if the preferredName or an alias isn't + * prefixed with enabledPrefix or disabledPrefix */ public Switch( final String enabledPrefix, @@ -126,6 +128,8 @@ this.prefixes = Collections.unmodifiableSet(newPrefixes); this.defaultSwitch = switchDefault; + +checkPrefixes(newPrefixes); } public void processParent( 1.3 +2 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/messages.properties Index: messages.properties === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/messages.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- messages.properties 22 Apr 2004 23:00:07 - 1.2 +++ messages.properties 7 Sep 2004 00:18:23 - 1.3 @@ -1,3 +1,5 @@ cli.error.minimum.exceeds.maximum = Minimum number of values must not exceed maximum number cli.error.too.few.defaults = Not enough default values. cli.error.too.many.defaults = Too many default values. +cli.error.trigger.needs.prefix = Trigger {0} must be prefixed with a value from {1} +cli.error.badproperty = Could not understand property: {0} 1.4 +38 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/OptionImpl.java Index: OptionImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/OptionImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- OptionImpl.java 6 Sep 2004 22:57:44 - 1.3 +++ OptionImpl.java 7 Sep 2004 00:18:23 - 1.4 @@ -15,11 +15,14 @@ */ package org.apache.commons.cli2.option
cvs commit: jakarta-commons/cli/xdocs/images logo.jpg
roxspring2004/09/02 06:54:39 Modified:cli project.xml Added: cli/xdocs/images logo.jpg Log: Tidied up project.xml, added jpeg version of commons-cli logo for pdf documentation Revision ChangesPath 1.23 +30 -16jakarta-commons/cli/project.xml Index: project.xml === RCS file: /home/cvs/jakarta-commons/cli/project.xml,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- project.xml 18 Aug 2004 00:44:46 - 1.22 +++ project.xml 2 Sep 2004 13:54:39 - 1.23 @@ -21,14 +21,14 @@ inceptionYear2002/inceptionYear shortDescriptionCommons CLI/shortDescription description - Commons CLI provides a simple API for presenting, proecessing and - validating a command line interface. +Commons CLI provides a simple API for presenting, proecessing and +validating a command line interface. /description - logo/images/logo.png/logo - + logo/images/logo.jpg/logo + urlhttp://jakarta.apache.org/commons/${pom.artifactId.substring(8)}//url packageorg.apache.commons.${pom.artifactId.substring(8)}/package - + organization nameApache Software Foundation/name urlhttp://www.apache.org/url @@ -40,12 +40,12 @@ siteAddressjakarta.apache.org/siteAddress siteDirectory/www/jakarta.apache.org/commons/${pom.artifactId.substring(8)}//siteDirectory distributionDirectory/www/jakarta.apache.org/builds/jakarta-commons/${pom.artifactId.substring(8)}//distributionDirectory - + repository connectionscm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:jakarta-commons/${pom.artifactId.substring(8)}/connection urlhttp://cvs.apache.org/viewcvs/jakarta-commons/${pom.artifactId.substring(8)}//url /repository - + mailingLists mailingList nameCommons Dev List/name @@ -73,23 +73,38 @@ idbob/id email[EMAIL PROTECTED]/email organizationWerken/organization + roles +rolecontributed ideas and code from werken.opt/role + /roles /developer developer nameJohn Keyes/name idjkeyes/id email[EMAIL PROTECTED]/email organizationintegral Source/organization + roles +rolecontributed ideas and code from Optz/role + /roles /developer developer nameRob Oxspring/name idroxspring/id email[EMAIL PROTECTED]/email - organization/organization + organizationIndigo Stone/organization + roles +roledesigned CLI2/role + /roles /developer /developers contributors -!-- Helped in merging Avalon CLI -- +contributor + namePeter Donald/name + iddonaldp/id + roles +rolecontributed ideas and code from Avalon Excalibur's cli package/role + /roles +/contributor contributor nameBerin Loritsch/name email[EMAIL PROTECTED]/email @@ -98,7 +113,6 @@ rolehelped in the Avalon CLI merge/role /roles /contributor -!-- Supplied patch -- contributor namePeter Maddocks/name email[EMAIL PROTECTED]/email @@ -110,24 +124,24 @@ /contributors dependencies - + dependency idcommons-lang/id version1.0/version /dependency - + dependency idjunit/id version3.8.1/version /dependency - + dependency idjdepend/id version2.5/version /dependency - + /dependencies - + build nagEmailAddress[EMAIL PROTECTED]/nagEmailAddress sourceDirectorysrc/java/sourceDirectory @@ -143,7 +157,7 @@ /includes /resource /resources - + !-- Unit test classes -- unitTest includes 1.1 jakarta-commons/cli/xdocs/images/logo.jpg Binary file - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli project.properties
roxspring2004/09/02 06:57:06 Modified:cli/xdocs navigation.xml cli project.properties Added: cli/xdocs navigation-pdf.xml Log: Navigation updated for v2 documentation PDF version separated out to exclude web only documents Revision ChangesPath 1.14 +20 -7 jakarta-commons/cli/xdocs/navigation.xml Index: navigation.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/navigation.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- navigation.xml22 Apr 2004 23:00:13 - 1.13 +++ navigation.xml2 Sep 2004 13:57:06 - 1.14 @@ -23,21 +23,34 @@ body links - item name=Jakarta Commons + item name=Jakarta Commons href=http://jakarta.apache.org/commons// /links -menu name=User Documentation - item name=Introduction href=/introduction.html/ +menu name=CLI2 + item name=Overview href=/manual/index.html/ + item name=Options href=/manual/options.html/ + item name=Builders href=/manual/builders.html/ + item name=CommandLines href=/manual/commandlines.html/ + item name=Validatorshref=/manual/validators.html/ + item name=Utilities href=/manual/utilities.html/ +/menu + +menu name=CLI1 + item name=Overview href=/introduction.html/ item name=Usage Scenarios href=/usage.html/ item name=Option Properties href=/properties.html/ - item name=Download href=http://jakarta.apache.org/builds/jakarta-commons/release/commons-cli/v1.0// /menu -menu name=Developer Documentation - item name=Versions and Branches href=/versions_and_branches.html/ +menu name=Examples + item name=Overview href=/examples/index.html/ + item name=ant href=/examples/ant.html/ + item name=lshref=/examples/ls.html/ + item name=cvs href=/examples/cvs.html/ + item name=cphref=/examples/cp.html/ /menu - + common-menus; + /body /project 1.1 jakarta-commons/cli/xdocs/navigation-pdf.xml Index: navigation-pdf.xml === ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2002-2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- !DOCTYPE org.apache.commons.menus SYSTEM '../../commons-build/menus/menus.dtd' project name=CLI titleCLI/title body links item name=Jakarta Commons href=http://jakarta.apache.org/commons// /links menu name=Command Line Interface item name=Introduction href=/index.html/ /menu menu name=CLI2 item name=CLI2 - Overview href=/manual/index.html/ item name=CLI2 - Options href=/manual/options.html/ item name=CLI2 - Builders href=/manual/builders.html/ item name=CLI2 - CommandLines href=/manual/commandlines.html/ item name=CLI2 - Validatorshref=/manual/validators.html/ item name=CLI2 - Utilities href=/manual/utilities.html/ /menu menu name=CLI1 item name=CLI1 - Overview href=/introduction.html/ item name=CLI1 - Usage Scenarios href=/usage.html/ item name=CLI1 - Option Properties href=/properties.html/ /menu menu name=Examples item name=Examples - Overview href=/examples/index.html/ item name=Examples - ant href=/examples/ant.html/ item name=Examples - lshref=/examples/ls.html/ item name=Examples - cvs href=/examples/cvs.html/ item name=Examples - cphref=/examples/cp.html/ /menu /body /project 1.11 +3 -1 jakarta-commons/cli/project.properties Index: project.properties === RCS file: /home/cvs/jakarta-commons/cli/project.properties,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- project.properties
cvs commit: jakarta-commons/cli/xdocs/manual - New directory
roxspring2004/09/02 06:57:57 jakarta-commons/cli/xdocs/manual - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/manual validators.xml builders.xml index.xml commandlines.xml utilities.xml options.xml
roxspring2004/09/02 06:58:02 Added: cli/xdocs/manual validators.xml builders.xml index.xml commandlines.xml utilities.xml options.xml Log: Added initial cli2 manual stub Revision ChangesPath 1.1 jakarta-commons/cli/xdocs/manual/validators.xml Index: validators.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- document properties author email=[EMAIL PROTECTED]commons-dev/author titleCLI2 - Validators/title /properties body section name=Validators img src=../images/validators.jpg/ subsection name=?? /subsection /section /body /document 1.1 jakarta-commons/cli/xdocs/manual/builders.xml Index: builders.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- document properties author email=[EMAIL PROTECTED]commons-dev/author titleCLI2 - Builders/title /properties body section name=Builders img src=../images/builders.jpg/ subsection name=GroupBuilder /subsection subsection name=ArgumentBuilder /subsection subsection name=DefaultOptionBuilder /subsection subsection name=CommandBuilder /subsection subsection name=SwitchBuilder /subsection subsection name=PatternBuilder /subsection subsection name=Other Options pTODO PropertyOption/p pTODO SourceDestArgument/p /subsection /section /body /document 1.1 jakarta-commons/cli/xdocs/manual/index.xml Index: index.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- document properties author email=[EMAIL PROTECTED]commons-dev/author titleCLI2 - Overview/title /properties body section name=Overview pTODO quick overview to the overview/p subsection name=Modelling the interface pTODO terminology/p pTODO basic options/p pTODO option builders/p /subsection subsection name=Parsing the command line pTODO Parser/p pTODO OptionException/p pTODO HelpFormatter/p /subsection subsection name=Querying the result pTODO CommandLine/p pTODO DefaultingCommandLine/p /subsection /section /body /document 1.1 jakarta-commons/cli/xdocs/manual/commandlines.xml Index: commandlines.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under
cvs commit: jakarta-commons/cli/xdocs/examples - New directory
roxspring2004/09/02 06:58:13 jakarta-commons/cli/xdocs/examples - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/examples index.xml ant.xml cp.xml ls.xml cvs.xml
roxspring2004/09/02 06:58:17 Added: cli/xdocs/examples index.xml ant.xml cp.xml ls.xml cvs.xml Log: Added initial cli2 examples stub Revision ChangesPath 1.1 jakarta-commons/cli/xdocs/examples/index.xml Index: index.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- document properties author email=[EMAIL PROTECTED]commons-dev/author titleExamples/title /properties body section name=Overview pTODO quick overview to the examples/p /section /body /document 1.1 jakarta-commons/cli/xdocs/examples/ant.xml Index: ant.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- document properties author email=[EMAIL PROTECTED]commons-dev/author titleExamples - ant/title /properties body section name=ant pTODO what is ant/p subsection name=Modelling /subsection subsection name=Querying /subsection subsection name=Helping /subsection /section /body /document 1.1 jakarta-commons/cli/xdocs/examples/cp.xml Index: cp.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- document properties author email=[EMAIL PROTECTED]commons-dev/author titleExamples - cp/title /properties body section name=cp pTODO what is cp/p subsection name=Modelling /subsection subsection name=Querying /subsection subsection name=Helping /subsection /section /body /document 1.1 jakarta-commons/cli/xdocs/examples/ls.xml Index: ls.xml === ?xml version=1.0? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- document properties author email=[EMAIL PROTECTED]commons-dev/author titleExamples - ls/title /properties body section name=ls pTODO what is ls/p subsection name=Modelling /subsection subsection name=Querying /subsection subsection name=Helping /subsection /section /body /document 1.1 jakarta-commons/cli/xdocs/examples/cvs.xml Index: cvs.xml === ?xml version=1.0? !-- Copyright 2004
cvs commit: jakarta-commons/cli/xdocs/images/svg - New directory
roxspring2004/09/02 06:59:13 jakarta-commons/cli/xdocs/images/svg - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/images/svg diagrams-cli2.js diagrams.css diagrams.js commandlines.svg util.svg options.svg
roxspring2004/09/02 07:00:47 Added: cli/xdocs/images/svg diagrams-cli2.js diagrams.css diagrams.js commandlines.svg util.svg options.svg Removed: cli/xdocs/images util.svg commandlines.svg diagrams.css diagrams.js diagrams-cli2.js options.svg Log: Moved svg diagrams into xdocs/images/svg directory (default dir for svg plugin) Revision ChangesPath 1.1 jakarta-commons/cli/xdocs/images/svg/diagrams-cli2.js Index: diagrams-cli2.js === /* * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var Option = new Interface(Option); Option.addMethod(process(...)); Option.addMethod(canProcess(...)); Option.addMethod(getTriggers()); Option.addMethod(getPrefixes()); Option.addMethod(validate(...)); Option.addMethod(helpLines(...)); Option.addMethod(appendUsage(...)); Option.addMethod(getPreferredName()); Option.addMethod(getDescription()); Option.addMethod(getId()); Option.addMethod(findOption(...)); var Group = new Interface(Group); Group.addMethod(appendUsage(...)); Group.addNote(-a | -b | -c | -d | -e); var Parent = new Interface(Parent); Parent.addMethod(processParent(...)); Parent.addNote(-f arg1); var Argument = new Interface(Argument); Argument.addMethod(getInitialSeparator()); Argument.addMethod(processValues(...)); Argument.addMethod(validate(...)); Argument.addNote(arg1 [arg2 ...]); var CommandLine = new Interface(CommandLine); CommandLine.addMethod(hasOption(...)); CommandLine.addMethod(getOption(...)); CommandLine.addMethod(getValue(...)); CommandLine.addMethod(getValues(...)); CommandLine.addMethod(getSwitch(...)); CommandLine.addMethod(getProperty(...)); CommandLine.addMethod(getProperties()); CommandLine.addMethod(getOptionCount(...)); CommandLine.addMethod(getOptions()); CommandLine.addMethod(getOptionTriggers()); var WriteableCommandLine = new Interface(WriteableCommandLine); WriteableCommandLine.addMethod(addOption(...)); WriteableCommandLine.addMethod(addValue(...)); WriteableCommandLine.addMethod(addSwitch(...)); WriteableCommandLine.addMethod(addProperty(...)); WriteableCommandLine.addMethod(looksLikeOption(...)); var PropertyOption = new Class(PropertyOption); PropertyOption.addAttribute(optionString); PropertyOption.addAttribute(description); PropertyOption.addAttribute(prefixes); PropertyOption.addNote(-Dproperty=value); var DefaultOption = new Class(DefaultOption); DefaultOption.addAttribute(optionString); DefaultOption.addAttribute(description); DefaultOption.addAttribute(prefixes); DefaultOption.addNote(-f (--file, --filelist)); var Command = new Class(Command); Command.addAttribute(preferredName); Command.addAttribute(aliases); Command.addAttribute(required); Command.addAttribute(triggers); Command.addNote(update (up, upd)); var Switch = new Class(Switch); Switch.addAttribute(enabledPrefix); Switch.addAttribute(disabledPrefix); Switch.addAttribute(preferredName); Switch.addAttribute(aliases); Switch.addAttribute(required); Switch.addAttribute(triggers); Switch.addAttribute(prefixes); Switch.addNote(+d|-d (+display|-display)); var SourceDestArgument = new Class(SourceDestArgument); SourceDestArgument.addAttribute(preferredName); SourceDestArgument.addAttribute(aliases); SourceDestArgument.addAttribute(required); SourceDestArgument.addAttribute(triggers); SourceDestArgument.addNote(src1 src2 ... dst); var Parser = new Class(Parser); Parser.addMethod(parse(...)); Parser.addMethod(parseAndHelp(...)); Parser.addMethod(setGroup(...)); Parser.addMethod(setHelpFormatter(...)); Parser.addMethod(setHelpOption(...)); Parser.addMethod(setHelpTrigger(...)); var DefaultingCommandLine = new Class(DefaultingCommandLine); DefaultingCommandLine.addMethod(appendCommandLine(...)); DefaultingCommandLine.addMethod(insertCommandLine(...)); DefaultingCommandLine.addMethod(commandLines()); var PropertiesCommandLine = new Class(PropertiesCommandLine); PropertiesCommandLine.addAttribute(properties); PropertiesCommandLine.addNote(java.util.Properties); var PreferencesCommandLine = new Class(PreferencesCommandLine
cvs commit: jakarta-commons/cli/xdocs/images/svg diagrams-cli2.js diagrams.css diagrams.js commandlines.svg util.svg options.svg
roxspring2004/09/02 07:01:29 Modified:cli/xdocs/images/svg diagrams-cli2.js diagrams.css diagrams.js commandlines.svg util.svg options.svg Log: Files are text based and mergeable Revision ChangesPath 1.2 +0 -0 jakarta-commons/cli/xdocs/images/svg/diagrams-cli2.js Index: diagrams-cli2.js === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/svg/diagrams-cli2.js,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 1.2 +0 -0 jakarta-commons/cli/xdocs/images/svg/diagrams.css Index: diagrams.css === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/svg/diagrams.css,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 1.2 +0 -0 jakarta-commons/cli/xdocs/images/svg/diagrams.js Index: diagrams.js === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/svg/diagrams.js,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 1.2 +0 -0 jakarta-commons/cli/xdocs/images/svg/commandlines.svg Index: commandlines.svg === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/svg/commandlines.svg,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 1.2 +0 -0 jakarta-commons/cli/xdocs/images/svg/util.svg Index: util.svg === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/svg/util.svg,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 1.2 +0 -0 jakarta-commons/cli/xdocs/images/svg/options.svg Index: options.svg === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/svg/options.svg,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/validation DateValidator.java
roxspring2004/09/02 07:45:52 Modified:cli/src/java/org/apache/commons/cli2/validation DateValidator.java Log: The array of permitted formats is not mutable Revision ChangesPath 1.3 +43 -4 jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/DateValidator.java Index: DateValidator.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/DateValidator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DateValidator.java22 Apr 2004 23:00:14 - 1.2 +++ DateValidator.java2 Sep 2004 14:45:51 - 1.3 @@ -29,7 +29,7 @@ public class DateValidator implements Validator { /** an array of permitted DateFormats */ -private final DateFormat[] formats; +private DateFormat[] formats; /** minimum Date allowed i.e: a valid date occurs later than this date */ private Date minimum; @@ -78,7 +78,7 @@ *a DateFormat which dates must conform to */ public DateValidator(final DateFormat format) { -this.formats = new DateFormat[] { format }; +setFormat(format); } /** @@ -88,8 +88,7 @@ *a List of DateFormats which dates must conform to */ public DateValidator(final List formats) { -this.formats = -(DateFormat[])formats.toArray(new DateFormat[formats.size()]); + setFormats(formats); } /** @@ -210,4 +209,44 @@ private boolean isDateEarlier(Date date) { return minimum != null date.getTime() minimum.getTime(); } + +/** + * Sets the date format permitted. + * + * @param format + * the format to use + */ +public void setFormat(final DateFormat format) { + formats = new DateFormat[]{format}; +} + +/** + * Sets the date formats permitted. + * + * @param formats + * the List of DateFormats to use + */ +public void setFormats(final List formats) { + setFormats((DateFormat[])formats.toArray(new DateFormat[formats.size()])); +} + +/** + * Sets the date formats permitted. + * + * @param formats + * the array of DateFormats to use + */ +public void setFormats(final DateFormat[] formats) { + this.formats = formats; +} + +/** + * Gets the date formats permitted. + * + * @return the permitted formats + */ +public DateFormat[] getFormats() { + return this.formats; +} + } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/validation EnumValidator.java
roxspring2004/09/02 07:48:56 Modified:cli/src/java/org/apache/commons/cli2/validation EnumValidator.java Log: The set of valid values is now mutable Revision ChangesPath 1.3 +14 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/EnumValidator.java Index: EnumValidator.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/EnumValidator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EnumValidator.java22 Apr 2004 23:00:14 - 1.2 +++ EnumValidator.java2 Sep 2004 14:48:56 - 1.3 @@ -83,4 +83,18 @@ return buff.toString(); } + +/** + * @return Returns the validValues. + */ +public Set getValidValues() { +return validValues; +} + +/** + * @param validValues The validValues to set. + */ +public void setValidValues(Set validValues) { +this.validValues = validValues; +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/validation NumberValidator.java
roxspring2004/09/02 07:49:23 Modified:cli/src/java/org/apache/commons/cli2/validation NumberValidator.java Log: The number format is now mutable Revision ChangesPath 1.3 +8 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/NumberValidator.java Index: NumberValidator.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/validation/NumberValidator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NumberValidator.java 22 Apr 2004 23:00:14 - 1.2 +++ NumberValidator.java 2 Sep 2004 14:49:23 - 1.3 @@ -55,7 +55,7 @@ return new NumberValidator(NumberFormat.getNumberInstance()); } -private final NumberFormat format; +private NumberFormat format; private Number minimum = null; private Number maximum = null; @@ -128,5 +128,12 @@ */ public void setMinimum(Number minimum) { this.minimum = minimum; +} + +/** + * @param format The format to set. + */ +public void setFormat(NumberFormat format) { +this.format = format; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/manual validators.xml
roxspring2004/09/02 10:25:26 Modified:cli/xdocs/manual validators.xml Log: Fleshed out the plans for the validators document Revision ChangesPath 1.2 +13 -1 jakarta-commons/cli/xdocs/manual/validators.xml Index: validators.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/manual/validators.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- validators.xml2 Sep 2004 13:58:02 - 1.1 +++ validators.xml2 Sep 2004 17:25:26 - 1.2 @@ -24,8 +24,20 @@ body section name=Validators img src=../images/validators.jpg/ - subsection name=?? + + subsection name=ClassValidator /subsection + subsection name=DateValidator + /subsection + subsection name=EnumValidator + /subsection + subsection name=FileValidator + /subsection + subsection name=NumberValidator + /subsection + subsection name=UrlValidator + /subsection + /section /body /document - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/images/svg diagrams-cli2.js
roxspring2004/09/02 10:25:49 Modified:cli/xdocs/images/svg diagrams-cli2.js Log: Added definitions for most classes Revision ChangesPath 1.3 +164 -2jakarta-commons/cli/xdocs/images/svg/diagrams-cli2.js Index: diagrams-cli2.js === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/svg/diagrams-cli2.js,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- diagrams-cli2.js 2 Sep 2004 14:01:28 - 1.2 +++ diagrams-cli2.js 2 Sep 2004 17:25:48 - 1.3 @@ -111,8 +111,6 @@ Parser.addMethod(setHelpOption(...)); Parser.addMethod(setHelpTrigger(...)); - - var DefaultingCommandLine = new Class(DefaultingCommandLine); DefaultingCommandLine.addMethod(appendCommandLine(...)); DefaultingCommandLine.addMethod(insertCommandLine(...)); @@ -126,3 +124,167 @@ PreferencesCommandLine.addAttribute(preferences); PreferencesCommandLine.addNote(java.util.prefs.Preferences); + + + + +var ArgumentBuilder = new Class(ArgumentBuilder); +ArgumentBuilder.addMethod(withId(...)); +ArgumentBuilder.addMethod(withName(...)); +ArgumentBuilder.addMethod(withDescription(...)); +ArgumentBuilder.addMethod(withConsumeRemaining(...)); +ArgumentBuilder.addMethod(withValidator(...)); +ArgumentBuilder.addMethod(withMinimum(...)); +ArgumentBuilder.addMethod(withMaximum(...)); +ArgumentBuilder.addMethod(withDefault(...)); +ArgumentBuilder.addMethod(withDefaults(...)); +ArgumentBuilder.addMethod(withInitialSeparator(...)); +ArgumentBuilder.addMethod(withSubsequentSeparator(...)); +ArgumentBuilder.addMethod(create()); +ArgumentBuilder.addMethod(reset()); + +var CommandBuilder = new Class(CommandBuilder); +CommandBuilder.addMethod(withId(...)); +CommandBuilder.addMethod(withName(...)); +CommandBuilder.addMethod(withDescription(...)); +CommandBuilder.addMethod(withArgument(...)); +CommandBuilder.addMethod(withChildren(...)); +CommandBuilder.addMethod(withRequired(...)); +CommandBuilder.addMethod(create()); +CommandBuilder.addMethod(reset()); + +var DefaultOptionBuilder = new Class(DefaultOptionBuilder); +DefaultOptionBuilder.addMethod(withId(...)); +DefaultOptionBuilder.addMethod(withShortName(...)); +DefaultOptionBuilder.addMethod(withLongName(...)); +DefaultOptionBuilder.addMethod(withDescription(...)); +DefaultOptionBuilder.addMethod(withArgument(...)); +DefaultOptionBuilder.addMethod(withChildren(...)); +DefaultOptionBuilder.addMethod(withRequired(...)); +DefaultOptionBuilder.addMethod(create()); +DefaultOptionBuilder.addMethod(reset()); +DefaultOptionBuilder.addAttribute(shortPrefix); +DefaultOptionBuilder.addAttribute(longPrefix); +DefaultOptionBuilder.addAttribute(burstEnabled); + +var DefaultOptionBuilder = new Class(DefaultOptionBuilder); +DefaultOptionBuilder.addMethod(withId(...)); +DefaultOptionBuilder.addMethod(withShortName(...)); +DefaultOptionBuilder.addMethod(withLongName(...)); +DefaultOptionBuilder.addMethod(withDescription(...)); +DefaultOptionBuilder.addMethod(withArgument(...)); +DefaultOptionBuilder.addMethod(withChildren(...)); +DefaultOptionBuilder.addMethod(withRequired(...)); +DefaultOptionBuilder.addMethod(create()); +DefaultOptionBuilder.addMethod(reset()); + +var GroupBuilder = new Class(GroupBuilder); +GroupBuilder.addMethod(withName(...)); +GroupBuilder.addMethod(withDescription(...)); +GroupBuilder.addMethod(withOption(...)); +GroupBuilder.addMethod(withMinimum(...)); +GroupBuilder.addMethod(withMaximum(...)); +GroupBuilder.addMethod(create()); +GroupBuilder.addMethod(reset()); + +var PatternBuilder = new Class(PatternBuilder); +PatternBuilder.addMethod(withPattern(...)); +PatternBuilder.addMethod(create()); +PatternBuilder.addMethod(reset()); +PatternBuilder.addAttribute(groupBuilder); +PatternBuilder.addAttribute(optionBuilder); +PatternBuilder.addAttribute(argumentBuilder); + +var SwitchBuilder = new Class(SwitchBuilder); +SwitchBuilder.addMethod(withId(...)); +SwitchBuilder.addMethod(withName(...)); +SwitchBuilder.addMethod(withDescription(...)); +SwitchBuilder.addMethod(withArgument(...)); +SwitchBuilder.addMethod(withChildren(...)); +SwitchBuilder.addMethod(withRequired(...)); +SwitchBuilder.addMethod(create()); +SwitchBuilder.addMethod(reset()); +SwitchBuilder.addAttribute(enabledPrefix); +SwitchBuilder.addAttribute(disabledPrefix); + + + +var Validator = new Class(Validator); +Validator.addMethod(validate(...)); + +var ClassValidator = new Class(ClassValidator); +ClassValidator.addAttribute(classLoader); +ClassValidator.addAttribute(instance); +ClassValidator.addAttribute(loadable); + +var DateValidator = new Class(DateValidator); +DateValidator.addAttribute(formats); +DateValidator.addAttribute(minimum); +DateValidator.addAttribute
cvs commit: jakarta-commons/cli/xdocs index.xml
roxspring2004/09/02 10:26:22 Modified:cli/xdocs index.xml Log: Added updated introduction documentation Revision ChangesPath 1.3 +27 -13jakarta-commons/cli/xdocs/index.xml Index: index.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/index.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- index.xml 22 Apr 2004 23:00:13 - 1.2 +++ index.xml 2 Sep 2004 17:26:22 - 1.3 @@ -17,29 +17,43 @@ document properties - title/title +titleIntroduction/title author email=[EMAIL PROTECTED]commons-dev/author /properties body - -section name=CLI : Command Line Interface - +section name=Jakarta Commons CLI p -The CLI library provides a simple and easy to use API for working -with the command line arguments and options. +The Jakarta Commons CLI library provides an API for processing command +line interfaces. /p p -CLI is based on ideas and code from +CLI1 was formed by the merger of ideas and code from three different +libraries and allows most simple interfaces to be modelled. CLI1 +became increasingly difficult to maintain and develop further and so +CLI2 has been developed with the goals of clearer responsibilities and +being more flexible. The intention is that CLI2 should be able to +model a far greater selection of interfaces and do so more completely, +validating as much as possible. + /p + p +The redesigned CLI2 is rooted in the codeorg.apache.commons.cli2/code +package and the distribution retains the codeorg.apache.commons.cli/code +package so that the upgrade doesn't break old code. The CLI1 package +should be regarded as deprecated to encourage the transition to the +more flexible CLI2 framework but minor bug fixes and patches may be +accepted to ensure that CLI1 based applications continue to function as +expected. + /p + p +The rest of the documentation is split into the followin three sections: ul - liwerken.opt by Bob Mcwhirter/li - liThe cli package in Avalon Excalibur by Peter Donald/li - liOptz by John Keyes/li + lia href=manual/index.htmlCLI2/a - a reference manual for version 2/li + lia href=introduction.htmlCLI1/a - documentation for version 1 /li + lia href=examples/index.htmlExamples/a - a selection of worked examples demonstrating CLI2 features/li /ul /p - /section - /body - + /document - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/style project.css
roxspring2004/08/19 13:18:17 Modified:cli/xdocs/style project.css Log: File is a text format Revision ChangesPath 1.2 +0 -0 jakarta-commons/cli/xdocs/style/project.css Index: project.css === RCS file: /home/cvs/jakarta-commons/cli/xdocs/style/project.css,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/images util.svg commandlines.svg diagrams.css diagrams.js diagrams-cli2.js options.svg
roxspring2004/08/19 13:18:57 Modified:cli/xdocs/images util.svg commandlines.svg diagrams.css diagrams.js diagrams-cli2.js options.svg Log: File is a text format Revision ChangesPath 1.3 +45 -45jakarta-commons/cli/xdocs/images/util.svg Index: util.svg === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/util.svg,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- util.svg 22 Apr 2004 23:00:06 - 1.2 +++ util.svg 19 Aug 2004 20:18:57 - 1.3 @@ -1,46 +1,46 @@ -?xml version=1.0 standalone=no? -!-- - * Copyright 2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. --- -!DOCTYPE svg PUBLIC -//W3C//DTD SVG 1.1//EN http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd; -svg width=1 height=1 - defs -marker -id=FilledArrow -viewBox=0 0 10 10 refX=0 refY=5 -markerUnits=strokeWidth -markerWidth=5 markerHeight=14 -orient=auto - -path -d=M 10 0 L 0 5 L 10 10 L 10 0 Z -fill=rgb(0,0,0) -/ -/marker -marker -id=HollowArrow -markerUnits=userSpaceOnUse -rexX=10 refY=5 -markerWidth=20 markerHeight=20 -orient=auto - -path -d=M 10 5 L 1 0 L 1 10 L 10 5 -fill=rgb(255,255,255) -stroke=rgb(0,0,0) -/ -/marker - /defs +?xml version=1.0 standalone=no? +!-- + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +-- +!DOCTYPE svg PUBLIC -//W3C//DTD SVG 1.1//EN http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd; +svg width=1 height=1 + defs +marker +id=FilledArrow +viewBox=0 0 10 10 refX=0 refY=5 +markerUnits=strokeWidth +markerWidth=5 markerHeight=14 +orient=auto + +path +d=M 10 0 L 0 5 L 10 10 L 10 0 Z +fill=rgb(0,0,0) +/ +/marker +marker +id=HollowArrow +markerUnits=userSpaceOnUse +rexX=10 refY=5 +markerWidth=20 markerHeight=20 +orient=auto + +path +d=M 10 5 L 1 0 L 1 10 L 10 5 +fill=rgb(255,255,255) +stroke=rgb(0,0,0) +/ +/marker + /defs /svg 1.3 +55 -55jakarta-commons/cli/xdocs/images/commandlines.svg Index: commandlines.svg === RCS file: /home/cvs/jakarta-commons/cli/xdocs/images/commandlines.svg,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- commandlines.svg 22 Apr 2004 23:00:06 - 1.2 +++ commandlines.svg 19 Aug 2004 20:18:57 - 1.3 @@ -1,56 +1,56 @@ -?xml version=1.0 standalone=no? -?xml-stylesheet type=text/css href=diagrams.css ? -!-- - * Copyright 2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS
cvs commit: jakarta-commons/cli build.xml gump.xml
roxspring2004/08/18 02:35:32 Modified:cli build.xml gump.xml Log: Brought build.xml and gump.xml inline with current maven POM Revision ChangesPath 1.4 +13 -9 jakarta-commons/cli/build.xml Index: build.xml === RCS file: /home/cvs/jakarta-commons/cli/build.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- build.xml 22 Apr 2004 23:00:15 - 1.3 +++ build.xml 18 Aug 2004 09:35:32 - 1.4 @@ -1,18 +1,20 @@ ?xml version=1.0 encoding=UTF-8? !--build.xml generated by maven from project.xml version 2.0 - on date April 22 2004, time 2325-- + on date August 18 2004, time 1029-- project default=jar name=commons-cli basedir=. property name=defaulttargetdir value=target /property - property name=libdir value=target/lib + property name=libdir value=${defaulttargetdir}/lib /property - property name=classesdir value=target/classes + property name=classesdir value=${defaulttargetdir}/classes /property - property name=testclassesdir value=target/test-classes + property name=testclassesdir value=${defaulttargetdir}/test-classes /property - property name=testreportdir value=target/test-reports + property name=testclassesdir value=${defaulttargetdir}/test-classes + /property + property name=testreportdir value=${defaulttargetdir}/test-reports /property property name=distdir value=dist /property @@ -43,7 +45,9 @@ /fileset /classpath /javac -copy todir=${classesdir} +mkdir dir=${classesdir}/org/apache/commons/cli2 +/mkdir +copy todir=${classesdir}/org/apache/commons/cli2 fileset dir=src/java/org/apache/commons/cli2 include name=**/*.properties /include @@ -51,7 +55,7 @@ /copy /target target name=jar description=o Create the jar depends=compile,test -jar jarfile=target/${final.name}.jar excludes=**/package.html basedir=${classesdir} +jar jarfile=${defaulttargetdir}/${final.name}.jar excludes=**/package.html basedir=${classesdir} /jar /target target name=clean description=o Clean up the generated directories @@ -133,13 +137,13 @@ /property property name=title value=CLI 2.0 API /property -javadoc use=true private=true destdir=${javadocdir} author=true version=true sourcepath=src/java packagenames=org.apache.commons.*.* +javadoc use=true private=true destdir=${javadocdir} author=true version=true sourcepath=src/java packagenames=org.apache.commons.cli.* classpath fileset dir=${libdir} include name=*.jar /include /fileset -pathelement location=target/${final.name}.jar +pathelement location=${defaulttargetdir}/${final.name}.jar /pathelement /classpath /javadoc 1.3 +5 -5 jakarta-commons/cli/gump.xml Index: gump.xml === RCS file: /home/cvs/jakarta-commons/cli/gump.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- gump.xml 22 Apr 2004 23:00:15 - 1.2 +++ gump.xml 18 Aug 2004 09:35:32 - 1.3 @@ -2,16 +2,16 @@ module name=commons-cli descriptionCommons CLI/description - url href=http://jakarta.apache.org/commons/index.html; + url href=http://jakarta.apache.org/commons/cli/; /url - cvs module=jakarta-commons repository=jakarta + cvs module=jakarta-commons/cli repository=jakarta /cvs project name=commons-cli -ant buildfile=build.xml target=dist +maven goal=jar property name=final.name value=commons-cli-@@DATE@@ /property -/ant -packageorg.apache.commons.*/package +/maven +packageorg.apache.commons.cli/package depend project=commons-lang /depend depend project=jakarta-ant - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli Util.java PatternOptionBuilder.java
roxspring2004/08/17 06:51:37 Modified:cli/src/java/org/apache/commons/cli2/option GroupImpl.java cli/src/java/org/apache/commons/cli Util.java PatternOptionBuilder.java Log: Removed some javadoc warnings Revision ChangesPath 1.3 +1 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/GroupImpl.java Index: GroupImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/GroupImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GroupImpl.java22 Apr 2004 23:00:07 - 1.2 +++ GroupImpl.java17 Aug 2004 13:51:36 - 1.3 @@ -451,7 +451,7 @@ /** * Gets a singleton instance of a ReverseStringComparator - * @return + * @return the singleton instance */ public static final Comparator getInstance() { return instance; 1.7 +2 -2 jakarta-commons/cli/src/java/org/apache/commons/cli/Util.java Index: Util.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Util.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Util.java 22 Apr 2004 23:00:09 - 1.6 +++ Util.java 17 Aug 2004 13:51:36 - 1.7 @@ -45,8 +45,8 @@ } /** - * pRemove the leading and trailing quotes from codestr/code, - * e.g. if str is 'one two', then 'one two' is returned./p + * Remove the leading and trailing quotes from codestr/code. + * E.g. if str is 'one two', then 'one two' is returned. * * @param str The string from which the leading and trailing quotes * should be removed. 1.10 +1 -1 jakarta-commons/cli/src/java/org/apache/commons/cli/PatternOptionBuilder.java Index: PatternOptionBuilder.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/PatternOptionBuilder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- PatternOptionBuilder.java 22 Apr 2004 23:00:09 - 1.9 +++ PatternOptionBuilder.java 17 Aug 2004 13:51:36 - 1.10 @@ -18,7 +18,7 @@ /** * Allows Options to be created from a single String. * - * @todo These need to break out to OptionType and also + * TODO These need to break out to OptionType and also * to be pluggable. * * @author Henri Yandell (bayard @ generationjava.com) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli README.txt
roxspring2004/08/17 16:19:50 Modified:cli README.txt Log: readme lists deprecate maven goal and old maven URL PR:30371 Submitted by: Brant Langer Gurganus Reviewed by: roxspring Revision ChangesPath 1.3 +2 -2 jakarta-commons/cli/README.txt Index: README.txt === RCS file: /home/cvs/jakarta-commons/cli/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- README.txt5 Nov 2002 22:54:24 - 1.2 +++ README.txt17 Aug 2004 23:19:50 - 1.3 @@ -24,11 +24,11 @@ Maven can be found here : - http://jakarta.apache.org/turbine/maven/ + http://maven.apache.org and to build and test the system use: - maven java:jar + maven jar:jar The system will build and test itself. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/conf MANIFEST.MF
roxspring2004/08/17 17:44:47 Modified:cli project.xml project.properties cli/src/conf MANIFEST.MF Log: Build system changes in preparation for 2.0B1 release Revision ChangesPath 1.22 +38 -9 jakarta-commons/cli/project.xml Index: project.xml === RCS file: /home/cvs/jakarta-commons/cli/project.xml,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- project.xml 22 Apr 2004 23:00:15 - 1.21 +++ project.xml 18 Aug 2004 00:44:46 - 1.22 @@ -15,17 +15,20 @@ limitations under the License. -- project - extend../commons-build/project.xml/extend idcommons-cli/id nameCLI/name currentVersion2.0/currentVersion inceptionYear2002/inceptionYear shortDescriptionCommons CLI/shortDescription description - Commons CLI provides a simple API for working with the command line arguments and options. + Commons CLI provides a simple API for presenting, proecessing and + validating a command line interface. /description logo/images/logo.png/logo - + + urlhttp://jakarta.apache.org/commons/${pom.artifactId.substring(8)}//url + packageorg.apache.commons.${pom.artifactId.substring(8)}/package + organization nameApache Software Foundation/name urlhttp://www.apache.org/url @@ -33,8 +36,31 @@ /organization gumpRepositoryIdjakarta/gumpRepositoryId - - + issueTrackingUrlhttp://issues.apache.org/bugzilla//issueTrackingUrl + siteAddressjakarta.apache.org/siteAddress + siteDirectory/www/jakarta.apache.org/commons/${pom.artifactId.substring(8)}//siteDirectory + distributionDirectory/www/jakarta.apache.org/builds/jakarta-commons/${pom.artifactId.substring(8)}//distributionDirectory + + repository +connectionscm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:jakarta-commons/${pom.artifactId.substring(8)}/connection + urlhttp://cvs.apache.org/viewcvs/jakarta-commons/${pom.artifactId.substring(8)}//url + /repository + + mailingLists +mailingList + nameCommons Dev List/name + subscribe[EMAIL PROTECTED]/subscribe + unsubscribe[EMAIL PROTECTED]/unsubscribe + archivehttp://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]/archive +/mailingList +mailingList + nameCommons User List/name + subscribe[EMAIL PROTECTED]/subscribe + unsubscribe[EMAIL PROTECTED]/unsubscribe + archivehttp://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]/archive +/mailingList + /mailingLists + developers developer nameJames Strachan/name @@ -43,7 +69,7 @@ organizationSpiritSoft, Inc./organization /developer developer - namebob mcwhirter/name + nameBob McWhirter/name idbob/id email[EMAIL PROTECTED]/email organizationWerken/organization @@ -106,6 +132,8 @@ nagEmailAddress[EMAIL PROTECTED]/nagEmailAddress sourceDirectorysrc/java/sourceDirectory unitTestSourceDirectorysrc/test/unitTestSourceDirectory +integrationUnitTestSourceDirectory/ +aspectSourceDirectory/ resources resource directorysrc/java/org/apache/commons/cli2/directory @@ -142,6 +170,7 @@ reportmaven-simian-plugin/report reportmaven-faq-plugin/report reportmaven-jcoverage-plugin/report -reportmaven-tasks-plugin/report -reportmaven-findbugs-plugin/report - /reports/project +!--reportmaven-tasks-plugin/report-- +!--reportmaven-findbugs-plugin/report-- + /reports +/project 1.10 +7 -3 jakarta-commons/cli/project.properties Index: project.properties === RCS file: /home/cvs/jakarta-commons/cli/project.properties,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- project.properties22 Apr 2004 23:00:15 - 1.9 +++ project.properties18 Aug 2004 00:44:46 - 1.10 @@ -7,9 +7,10 @@ compile.deprecation = off maven.jarResources.basedir=${basedir}/src/java - -# use turbine coding standards -maven.checkstyle.format = sun + +# Reset the checkstyle properties to use the default sun settings +maven.checkstyle.properties= +maven.checkstyle.format=sun maven.xdoc.jsl=../commons-build/commons-site.jsl maven.xdoc.date=left @@ -18,3 +19,6 @@ maven.xdoc.poweredby.image=maven-feather.png maven.javadoc.links=http://java.sun.com/j2se/1.4/docs/api/ + + +maven.jar.manifest=${basedir}/src/conf/MANIFEST.MF \ No newline at end of file 1.3 +8 -5 jakarta-commons/cli/src/conf/MANIFEST.MF Index: MANIFEST.MF
cvs commit: jakarta-commons/cli/xdocs properties.xml introduction.xml
roxspring2004/07/22 13:58:12 Modified:cli/xdocs properties.xml introduction.xml Log: More doc corrections from Dennis PR:30089 Submitted by: Dennis Lundberg Revision ChangesPath 1.4 +2 -2 jakarta-commons/cli/xdocs/properties.xml Index: properties.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/properties.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- properties.xml22 Apr 2004 23:00:13 - 1.3 +++ properties.xml22 Jul 2004 20:58:11 - 1.4 @@ -25,9 +25,9 @@ section name=Option Properties p The following are the properties that each -a href=apidocs/org/apache/commons/cli/Options.htmlOption/a has. All of these +a href=apidocs/org/apache/commons/cli/Option.htmlOption/a has. All of these can be set using the accessors or using the methods -defined on the +defined in the a href=apidocs/org/apache/commons/cli/OptionBuilder.htmlOptionBuilder/a. /p table 1.6 +3 -7 jakarta-commons/cli/xdocs/introduction.xml Index: introduction.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/introduction.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- introduction.xml 22 Apr 2004 23:00:13 - 1.5 +++ introduction.xml 22 Jul 2004 20:58:11 - 1.6 @@ -38,9 +38,9 @@ p CLI uses the a href=apidocs/org/apache/commons/cli/Options.html Options/a class, as a container for -a href=apidocs/org/apache/commons/cli/Options.html +a href=apidocs/org/apache/commons/cli/Option.html Option/a instances. There are two ways to create -codeOption/codes in CLI. One of them is via the constuctors, +codeOption/codes in CLI. One of them is via the constructors, the other way is via the factory methods defined in codeOptions/code. /p @@ -79,17 +79,13 @@ p The interrogation stage is where the application querys the codeCommandLine/code to decide what execution branch to -take depending on boolean options and to use the option values +take depending on boolean options and uses the option values to provide the application data. /p p This stage is implemented in the user code. The accessor methods on codeCommandLine/code provide the interrogation capability to the user code. - /p - p -The a href=usage.htmlUsage Scenarios/a document provides examples -how to create an codeOptions/code object. /p p The result of the interrogation stage is that the user code - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs usage.xml
roxspring2004/07/21 14:16:35 Modified:cli/xdocs usage.xml Log: Documentation fixes PR:30089 Submitted by: Dennis Lundberg Reviewed by: roxspring Revision ChangesPath 1.6 +28 -25jakarta-commons/cli/xdocs/usage.xml Index: usage.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/usage.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- usage.xml 22 Apr 2004 23:00:13 - 1.5 +++ usage.xml 21 Jul 2004 21:16:35 - 1.6 @@ -32,7 +32,7 @@ p A boolean option is represented on a command line by the presence of the option, i.e. if the option is found then the option value - is true, otherwise the value is false. + is codetrue/code, otherwise the value is codefalse/code. /p p The codeDateApp/code utility prints the current date to standard @@ -43,7 +43,7 @@ subsection name=Create the Options p An a href=apidocs/org/apache/commons/cli/Options.html - Options/a object must be created and thecodeOption/code must be + Options/a object must be created and the codeOption/code must be added to it. /p source @@ -55,10 +55,10 @@ p The codeaddOption/code method has three parameters. The first parameter is a codejava.lang.String/code that represents the option. -Thesecond paramter is a codeboolean/code that specifies whether the +The second parameter is a codeboolean/code that specifies whether the option requires an argument or not. In the case of a boolean option (sometimes referred to as a flag) an argument value is not present so -it codefalse/code is passed. The third parameter is the description +codefalse/code is passed. The third parameter is the description of the option. This description will be used in the usage text of the application. /p @@ -66,7 +66,9 @@ subsection name=Parsing the command line arguments p The codeparse/code methods of codeCommandLineParser/code are used - to parse the command line arguments. + to parse the command line arguments. The codePosixPaser/code is + great when you need to handle options that are one character long, + like the codet/code option in this example. /p sourceCommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse( options, args);/source @@ -75,9 +77,9 @@ this we will interrogate the a href=apidocs/org/apache/commons/cli/CommandLine.htmlCommandLine /a object. The codehasOption/code method takes a - codejava.lang.String/code parameter and returns true if the option + codejava.lang.String/code parameter and returns codetrue/code if the option represented by the codejava.lang.String/code is present, otherwise - it returns false. + it returns codefalse/code. /p sourceif(cmd.hasOption(t)) { // print the date and time @@ -96,7 +98,7 @@ source// add c option options.addOption(c, true, country code);/source p - The second parameter is true this time. This specifies that the + The second parameter is codetrue/code this time. This specifies that the codec/code option requires an argument value. If the required option argument value is specified on the command line it is returned, otherwise codenull/code is returned. @@ -104,11 +106,11 @@ /subsection subsection name=Retrieving the argument value p - The codegetOptionValue/code methods of codeOptions/code are + The codegetOptionValue/code methods of codeCommandLine/code are used to retrieve the argument values of options. /p source// get c option value -String countryCode = options.getOptionValue(c); +String countryCode = cmd.getOptionValue(c); if(countryCode == null) { // print default date @@ -121,9 +123,9 @@ section name=Ant Example p -As one of the most ubquituous Java applications -a href=http://jakarta.apache.org/ant;Ant/a it will be used -here to illustrate how to create the Options required. The following +One of the most ubiquitous Java applications +a href=http://ant.apache.org/;Ant/a will be used +here to illustrate how to create the codeOptions/code required. The following is the help output for Ant. /p sourceant [options
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/option SourceDestArgument.java
roxspring2004/05/05 14:28:50 Modified:cli/src/java/org/apache/commons/cli2/option SourceDestArgument.java Log: SourceDestArgument has no need to reference ArgumentImpl anymore, replaced with Argument instead Revision ChangesPath 1.3 +7 -6 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/SourceDestArgument.java Index: SourceDestArgument.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/SourceDestArgument.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SourceDestArgument.java 22 Apr 2004 23:00:07 - 1.2 +++ SourceDestArgument.java 5 May 2004 21:28:50 - 1.3 @@ -21,6 +21,7 @@ import java.util.List; import java.util.Set; +import org.apache.commons.cli2.Argument; import org.apache.commons.cli2.Option; import org.apache.commons.cli2.OptionException; import org.apache.commons.cli2.WriteableCommandLine; @@ -36,8 +37,8 @@ return Math.max(a, Math.max(b, a + b)); } -private final ArgumentImpl source; -private final ArgumentImpl dest; +private final Argument source; +private final Argument dest; /** * Creates a SourceDestArgument using defaults where possible. @@ -46,8 +47,8 @@ * @param dest the fixed size Argument */ public SourceDestArgument( -final ArgumentImpl source, -final ArgumentImpl dest) { +final Argument source, +final Argument dest) { this( source, dest, @@ -68,8 +69,8 @@ * @param defaultValues the default values for the SourceDestArgument */ public SourceDestArgument( -final ArgumentImpl source, -final ArgumentImpl dest, +final Argument source, +final Argument dest, final char initialSeparator, final char subsequentSeparator, final String consumeRemaining, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/util Comparators.java
roxspring2004/04/22 13:22:27 Modified:cli/src/java/org/apache/commons/cli2/util Tag: RESEARCH_CLI_2_ROXSPRING Comparators.java Log: Required comparator is now private and documented Revision ChangesPath No revision No revision 1.1.2.5 +13 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/util/Attic/Comparators.java Index: Comparators.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/util/Attic/Comparators.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- Comparators.java 20 Apr 2004 21:43:33 - 1.1.2.4 +++ Comparators.java 22 Apr 2004 20:22:27 - 1.1.2.5 @@ -435,15 +435,27 @@ } } +/** + * Orders Options grouping required Options first + * + * @see Option#isRequired() + * @return a new comparator + */ public static Comparator requiredFirst() { return new Required(); } +/** + * Orders Options grouping required Options last + * + * @see Option#isRequired() + * @return a new comparator + */ public static Comparator requiredLast() { return reverse(requiredFirst()); } -public static class Required implements Comparator { +private static class Required implements Comparator { public int compare(final Object oleft, final Object oright) { final Option left = (Option)oleft; final Option right = (Option)oright; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/validation ClassValidator.java
roxspring2004/04/22 13:26:05 Modified:cli/src/java/org/apache/commons/cli2/option Tag: RESEARCH_CLI_2_ROXSPRING GroupImpl.java Switch.java Command.java OptionImpl.java DefaultOption.java ParentImpl.java ArgumentImpl.java cli/src/java/org/apache/commons/cli2/builder Tag: RESEARCH_CLI_2_ROXSPRING GroupBuilder.java ArgumentBuilder.java DefaultOptionBuilder.java CommandBuilder.java SwitchBuilder.java cli/src/java/org/apache/commons/cli2/validation Tag: RESEARCH_CLI_2_ROXSPRING ClassValidator.java Log: Fixed up javadoc warnings Fixed up eclipse 'local variable hiding field' warnings Revision ChangesPath No revision No revision 1.1.2.5 +9 -9 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/GroupImpl.java Index: GroupImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/GroupImpl.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- GroupImpl.java20 Apr 2004 20:59:19 - 1.1.2.4 +++ GroupImpl.java22 Apr 2004 20:26:05 - 1.1.2.5 @@ -78,14 +78,14 @@ this.options = Collections.unmodifiableList(options); // anonymous Argument temporary storage -final List anonymous = new ArrayList(); +final List newAnonymous = new ArrayList(); // map (key=trigger value=Option) temporary storage -final SortedMap optionMap = +final SortedMap newOptionMap = new TreeMap(ReverseStringComparator.getInstance()); // prefixes temporary storage -final Set prefixes = new HashSet(); +final Set newPrefixes = new HashSet(); // process the options for (final Iterator i = options.iterator(); i.hasNext();) { @@ -94,23 +94,23 @@ if (option instanceof Argument) { i.remove(); -anonymous.add(option); +newAnonymous.add(option); } else { final Set triggers = option.getTriggers(); for (Iterator j = triggers.iterator(); j.hasNext();) { -optionMap.put(j.next(), option); +newOptionMap.put(j.next(), option); } // store the prefixes -prefixes.addAll(option.getPrefixes()); +newPrefixes.addAll(option.getPrefixes()); } } -this.anonymous = Collections.unmodifiableList(anonymous); -this.optionMap = Collections.unmodifiableSortedMap(optionMap); -this.prefixes = Collections.unmodifiableSet(prefixes); +this.anonymous = Collections.unmodifiableList(newAnonymous); +this.optionMap = Collections.unmodifiableSortedMap(newOptionMap); +this.prefixes = Collections.unmodifiableSet(newPrefixes); } public boolean canProcess(String arg) { 1.1.2.4 +10 -10 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/Switch.java Index: Switch.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/Switch.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- Switch.java 20 Apr 2004 20:59:19 - 1.1.2.3 +++ Switch.java 22 Apr 2004 20:26:05 - 1.1.2.4 @@ -101,10 +101,10 @@ throw new IllegalArgumentException(preferredName must be at least 1 character); } -final Set triggers = new HashSet(); -triggers.add(enabledPrefix + preferredName); -triggers.add(disabledPrefix + preferredName); -this.triggers = Collections.unmodifiableSet(triggers); +final Set newTriggers = new HashSet(); +newTriggers.add(enabledPrefix + preferredName); +newTriggers.add(disabledPrefix + preferredName); +this.triggers = Collections.unmodifiableSet(newTriggers); if (aliases == null) { this.aliases = Collections.EMPTY_SET; @@ -113,15 +113,15 @@ this.aliases = Collections.unmodifiableSet(new HashSet(aliases)); for (final Iterator i = aliases.iterator(); i.hasNext();) { final String alias = (String)i.next(); -triggers.add(enabledPrefix + alias); -triggers.add(disabledPrefix + alias); +newTriggers.add(enabledPrefix + alias
cvs commit: jakarta-commons/cli project.properties
roxspring2004/04/22 13:28:17 Modified:cli Tag: RESEARCH_CLI_2_ROXSPRING project.properties Log: Pointed javadoc links at 1.4 docs since 1.4 features are optionally used Revision ChangesPath No revision No revision 1.7.2.2 +1 -1 jakarta-commons/cli/project.properties Index: project.properties === RCS file: /home/cvs/jakarta-commons/cli/project.properties,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -u -r1.7.2.1 -r1.7.2.2 --- project.properties10 Feb 2004 22:00:30 - 1.7.2.1 +++ project.properties22 Apr 2004 20:28:17 - 1.7.2.2 @@ -16,4 +16,4 @@ maven.xdoc.developmentProcessUrl=http://jakarta.apache.org/commons/charter.html maven.xdoc.poweredby.image=maven-feather.png -maven.javadoc.links=http://java.sun.com/j2se/1.3/docs/api/ +maven.javadoc.links=http://java.sun.com/j2se/1.4/docs/api/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli .cvsignore
roxspring2004/04/22 13:28:53 Modified:cli Tag: RESEARCH_CLI_2_ROXSPRING .cvsignore Log: CVS now ignores jcoverage temporary file Revision ChangesPath No revision No revision 1.2.4.1 +1 -1 jakarta-commons/cli/.cvsignore Index: .cvsignore === RCS file: /home/cvs/jakarta-commons/cli/.cvsignore,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -r1.2 -r1.2.4.1 --- .cvsignore1 Jan 2003 04:30:22 - 1.2 +++ .cvsignore22 Apr 2004 20:28:52 - 1.2.4.1 @@ -3,6 +3,6 @@ target velocity.log .project - maven.log .classpath +jcoverage.ser - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli project.xml
roxspring2004/04/22 13:31:02 Modified:cli/xdocs Tag: RESEARCH_CLI_2_ROXSPRING navigation.xml cli Tag: RESEARCH_CLI_2_ROXSPRING project.xml Log: Bringing cli2 in line with commons-build changes Revision ChangesPath No revision No revision 1.10.2.2 +3 -5 jakarta-commons/cli/xdocs/navigation.xml Index: navigation.xml === RCS file: /home/cvs/jakarta-commons/cli/xdocs/navigation.xml,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -u -r1.10.2.1 -r1.10.2.2 --- navigation.xml19 Feb 2004 23:07:03 - 1.10.2.1 +++ navigation.xml22 Apr 2004 20:31:02 - 1.10.2.2 @@ -15,9 +15,7 @@ limitations under the License. -- -!DOCTYPE project [ -!ENTITY commons-nav SYSTEM ../../incl_nav.xml -] +!DOCTYPE org.apache.commons.menus SYSTEM '../../commons-build/menus/menus.dtd' project name=CLI @@ -33,13 +31,13 @@ item name=Introduction href=/introduction.html/ item name=Usage Scenarios href=/usage.html/ item name=Option Properties href=/properties.html/ - item name=Download href=http://jakarta.apache.org/builds/jakarta-commons/release/commons-cli/v1.0// + item name=Download href=http://jakarta.apache.org/builds/jakarta-commons/release/commons-cli/v1.0// /menu menu name=Developer Documentation item name=Versions and Branches href=/versions_and_branches.html/ /menu -commons-nav; +common-menus; /body /project No revision No revision 1.16.2.9 +3 -1 jakarta-commons/cli/project.xml Index: project.xml === RCS file: /home/cvs/jakarta-commons/cli/project.xml,v retrieving revision 1.16.2.8 retrieving revision 1.16.2.9 diff -u -r1.16.2.8 -r1.16.2.9 --- project.xml 19 Apr 2004 22:11:47 - 1.16.2.8 +++ project.xml 22 Apr 2004 20:31:02 - 1.16.2.9 @@ -90,8 +90,10 @@ /dependencies build +nagEmailAddress[EMAIL PROTECTED]/nagEmailAddress sourceDirectorysrc/java/sourceDirectory - resources +unitTestSourceDirectorysrc/test/unitTestSourceDirectory +resources resource directorysrc/java/org/apache/commons/cli2/directory targetPathorg/apache/commons/cli2/targetPath - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/protect ProtectedClass.java
roxspring2004/04/22 16:00:16 Modified:cli/src/test/org/apache/commons/cli OptionsTest.java OptionBuilderTest.java BuildTest.java BugsTest.java HelpFormatterExamples.java OptionGroupTest.java ValueTest.java ParseTest.java TestHelpFormatter.java GnuParseTest.java ValuesTest.java PatternOptionBuilderTest.java ParseRequiredTest.java ApplicationTest.java cli/src/java/org/apache/commons/cli PatternOptionBuilder.java package.html Option.java UnrecognizedOptionException.java HelpFormatter.java Parser.java OptionValidator.java Options.java PosixParser.java AlreadySelectedException.java Util.java BasicParser.java OptionGroup.java ParseException.java OptionBuilder.java MissingOptionException.java MissingArgumentException.java CommandLine.java CommandLineParser.java GnuParser.java TypeHandler.java cli/xdocs versions_and_branches.xml navigation.xml properties.xml index.xml usage.xml introduction.xml cli project.xml maven.xml LICENSE.txt .cvsignore gump.xml build.xml project.properties cli/src/conf MANIFEST.MF Added: cli/src/java/org/apache/commons/cli2 Argument.java DisplaySetting.java Group.java WriteableCommandLine.java Parent.java OptionException.java CommandLine.java messages.properties HelpLine.java Option.java cli/xdocs/images diagrams.js diagrams.css commandlines.svg commandlines.png util.svg options.png diagrams-cli2.js options.svg cli/src/test/org/apache/commons/cli2 DocumentationTest.java PrecedenceTest.java CLITestCase.java WriteableCommandLineTestCase.java CommandLineTestCase.java cli/src/test/org/apache/commons/cli CLI2ConverterTest.java cli/src/java/org/apache/commons/cli2/option Command.java Switch.java DefaultOption.java ArgumentImpl.java OptionImpl.java PropertyOption.java SourceDestArgument.java GroupImpl.java HelpLineImpl.java ParentImpl.java messages.properties cli/src/test/org/apache/commons/cli2/commandline PropertiesCommandLineTest.java DefaultingCommandLineTest.java PreferencesCommandLineTest.java WriteableCommandLineImplTest.java cli/src/java/org/apache/commons/cli CLI2Converter.java cli/src/test/org/apache/commons/cli2/application CvsTest.java CpTest.java LsTest.java AntTest.java cli/src/java/org/apache/commons/cli2/validation messages.properties DateValidator.java NumberValidator.java InvalidArgumentException.java FileValidator.java ClassValidator.java EnumValidator.java UrlValidator.java Validator.java cli/src/test/org/apache/commons/cli2/option GroupTest.java DefaultOptionTest.java SwitchTest.java ArgumentTest.java CommandTest.java ArgumentTestCase.java ParentTestCase.java PropertyOptionTest.java GroupTestCase.java ParentTest.java OptionTestCase.java cli/src/test/org/apache/commons/cli2/util ComparatorsTest.java HelpFormatterTest.java cli/src/java/org/apache/commons/cli2/builder ArgumentBuilder.java PatternBuilder.java CommandBuilder.java GroupBuilder.java DefaultOptionBuilder.java SwitchBuilder.java cli/src/java/org/apache/commons/cli2/commandline PropertiesCommandLine.java CommandLineImpl.java DefaultingCommandLine.java Parser.java WriteableCommandLineImpl.java PreferencesCommandLine.java cli/src/test/org/apache/commons/cli2/validation DateValidatorTest.java UrlValidatorTest.java EnumValidatorTest.java ClassValidatorTest.java FileValidatorTest.java NumberValidatorTest.java cli/src/test/org/apache/commons/cli2/builder
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2 Argument.java Group.java Option.java
roxspring2004/04/20 13:59:19 Modified:cli/src/java/org/apache/commons/cli2/option Tag: RESEARCH_CLI_2_ROXSPRING PropertyOption.java GroupImpl.java DefaultOption.java Switch.java ParentImpl.java OptionImpl.java Command.java ArgumentImpl.java cli/src/java/org/apache/commons/cli2 Tag: RESEARCH_CLI_2_ROXSPRING Argument.java Group.java Option.java Log: isRequired(), getMinimum() and getMaximum() refactored into the Option, Argument and Group interfaces Revision ChangesPath No revision No revision 1.1.2.3 +1 -1 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/PropertyOption.java Index: PropertyOption.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/PropertyOption.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- PropertyOption.java 14 Apr 2004 18:31:16 - 1.1.2.2 +++ PropertyOption.java 20 Apr 2004 20:59:19 - 1.1.2.3 @@ -57,7 +57,7 @@ final String optionString, final String description, final int id) { -super(id); +super(id,false); this.optionString = optionString; this.description = description; this.prefixes = Collections.singleton(optionString); 1.1.2.4 +5 -9 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/GroupImpl.java Index: GroupImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/GroupImpl.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- GroupImpl.java19 Apr 2004 21:35:10 - 1.1.2.3 +++ GroupImpl.java20 Apr 2004 20:59:19 - 1.1.2.4 @@ -66,7 +66,7 @@ final int minimum, final int maximum) { -super(0); +super(0,false); this.name = name; this.description = description; @@ -433,21 +433,17 @@ return null; } - /** - * Gets the minimum number of member Options for a valid CommandLine - * @return the minimum number of member Options - */ public int getMinimum() { return minimum; } -/** - * Gets the maximum number of member Options for a valid CommandLine - * @return the maximum number of member Options - */ public int getMaximum() { return maximum; } + +public boolean isRequired() { +return getMinimum()0; +} } class ReverseStringComparator implements Comparator { 1.1.2.3 +3 -13 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/DefaultOption.java Index: DefaultOption.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/DefaultOption.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- DefaultOption.java14 Apr 2004 18:31:16 - 1.1.2.2 +++ DefaultOption.java20 Apr 2004 20:59:19 - 1.1.2.3 @@ -53,7 +53,6 @@ private final String preferredName; private final Set aliases; private final Set burstAliases; -private final boolean required; private final Set triggers; private final Set prefixes; @@ -89,7 +88,7 @@ final Argument argument, final Group children, final int id) { -super(argument, children, description, id); +super(argument, children, description, id, required); this.shortPrefix = shortPrefix; this.burstEnabled = burstEnabled; @@ -111,7 +110,6 @@ this.burstAliases = Collections.unmodifiableSet(new HashSet(burstAliases)); } -this.required = required; final Set triggers = new HashSet(); triggers.add(preferredName); @@ -181,7 +179,7 @@ public void validate(WriteableCommandLine commandLine) throws OptionException { -if (required !commandLine.hasOption(this)) { +if (isRequired() !commandLine.hasOption(this)) { throw new OptionException(this); } @@ -195,7 +193,7 @@ // do we display optionality final boolean optional = -!required helpSettings.contains(DisplaySetting.DISPLAY_OPTIONAL); +!isRequired() helpSettings.contains
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/util Comparators.java
roxspring2004/04/20 14:43:33 Modified:cli/src/java/org/apache/commons/cli2/util Tag: RESEARCH_CLI_2_ROXSPRING Comparators.java Log: Added requiredFirst(..) and requiredLast(..) to Comparators to allow required options to be sorted to one end of a list PR:26926 Revision ChangesPath No revision No revision 1.1.2.4 +30 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/util/Attic/Comparators.java Index: Comparators.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/util/Attic/Comparators.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- Comparators.java 14 Apr 2004 18:31:16 - 1.1.2.3 +++ Comparators.java 20 Apr 2004 21:43:33 - 1.1.2.4 @@ -434,4 +434,34 @@ return left.getPreferredName().compareTo(right.getPreferredName()); } } + +public static Comparator requiredFirst() { +return new Required(); +} + +public static Comparator requiredLast() { +return reverse(requiredFirst()); +} + +public static class Required implements Comparator { +public int compare(final Object oleft, final Object oright) { +final Option left = (Option)oleft; +final Option right = (Option)oright; + +final boolean l = left.isRequired(); +final boolean r = right.isRequired(); + +if (l ^ r) { +if (l) { +return -1; +} +else { +return 1; +} +} +else { +return 0; +} +} +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2/util ComparatorsTest.java
roxspring2004/04/20 14:48:59 Modified:cli/src/test/org/apache/commons/cli2/util Tag: RESEARCH_CLI_2_ROXSPRING ComparatorsTest.java Log: Added tests for requiredFirst(..) and requiredLast(..). Fixed tests to correctly test order. Revision ChangesPath No revision No revision 1.1.2.3 +68 -55 jakarta-commons/cli/src/test/org/apache/commons/cli2/util/Attic/ComparatorsTest.java Index: ComparatorsTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/util/Attic/ComparatorsTest.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- ComparatorsTest.java 1 Apr 2004 21:13:36 - 1.1.2.2 +++ ComparatorsTest.java 20 Apr 2004 21:48:59 - 1.1.2.3 @@ -36,39 +36,36 @@ public void testGroupFirst() { final Option o1 = GroupTest.buildAntGroup(); final Option o2 = ParentTest.buildLibParent(); -final Option o3 = GroupTest.buildApachectlGroup(); -final List list = OptionTestCase.list(o1, o2, o3); +final List list = OptionTestCase.list(o1, o2); Collections.sort(list, Comparators.groupFirst()); -OptionTestCase.assertContentsEqual( -OptionTestCase.list(o1, o3, o2), +OptionTestCase.assertListContentsEqual( +OptionTestCase.list(o1, o2), list); } public void testGroupLast() { final Option o1 = GroupTest.buildAntGroup(); final Option o2 = ParentTest.buildLibParent(); -final Option o3 = GroupTest.buildApachectlGroup(); -final List list = OptionTestCase.list(o1, o2, o3); +final List list = OptionTestCase.list(o1, o2); Collections.sort(list, Comparators.groupLast()); -OptionTestCase.assertContentsEqual( -OptionTestCase.list(o2, o1, o3), +OptionTestCase.assertListContentsEqual( +OptionTestCase.list(o2, o1), list); } public void testSwitchFirst() { final Option o1 = SwitchTest.buildDisplaySwitch(); final Option o2 = ParentTest.buildLibParent(); -final Option o3 = new SwitchBuilder().withName(hidden).create(); -final List list = OptionTestCase.list(o1, o2, o3); +final List list = OptionTestCase.list(o1, o2); Collections.sort(list, Comparators.switchFirst()); -OptionTestCase.assertContentsEqual( -OptionTestCase.list(o1, o3, o2), +OptionTestCase.assertListContentsEqual( +OptionTestCase.list(o1, o2), list); } @@ -76,116 +73,132 @@ final Option o1 = SwitchTest.buildDisplaySwitch(); final Option o2 = ParentTest.buildLibParent(); final Option o3 = new SwitchBuilder().withName(hidden).create(); -final List list = OptionTestCase.list(o1, o2, o3); +final List list = OptionTestCase.list(o1, o2); Collections.sort(list, Comparators.switchLast()); -OptionTestCase.assertContentsEqual( -OptionTestCase.list(o2, o1, o3), +OptionTestCase.assertListContentsEqual( +OptionTestCase.list(o2, o1), list); } public void testCommandFirst() { final Option o1 = CommandTest.buildCommitCommand(); final Option o2 = ParentTest.buildLibParent(); -final Option o3 = CommandTest.buildStartCommand(); -final List list = OptionTestCase.list(o1, o2, o3); +final List list = OptionTestCase.list(o1, o2); Collections.sort(list, Comparators.commandFirst()); -OptionTestCase.assertContentsEqual( -OptionTestCase.list(o1, o3, o2), +OptionTestCase.assertListContentsEqual( +OptionTestCase.list(o1, o2), list); } public void testCommandLast() { final Option o1 = CommandTest.buildCommitCommand(); final Option o2 = ParentTest.buildLibParent(); -final Option o3 = CommandTest.buildStartCommand(); -final List list = OptionTestCase.list(o1, o2, o3); +final List list = OptionTestCase.list(o1, o2); Collections.sort(list, Comparators.commandLast()); -OptionTestCase.assertContentsEqual( -OptionTestCase.list(o1, o3, o2), +OptionTestCase.assertListContentsEqual( +OptionTestCase.list(o2, o1), list); } public void testDefaultOptionFirst() { final Option o1 = DefaultOptionTest.buildHelpOption(); -final Option o2 = ParentTest.buildLibParent(); -final Option o3 = DefaultOptionTest.buildXOption
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2/validation UrlValidatorTest.java EnumValidatorTest.java FileValidatorTest.java NumberValidatorTest.java
roxspring2004/04/20 16:18:58 Modified:cli/src/test/org/apache/commons/cli2/validation Tag: RESEARCH_CLI_2_ROXSPRING NumberValidatorTest.java Added: cli/src/test/org/apache/commons/cli2/validation Tag: RESEARCH_CLI_2_ROXSPRING UrlValidatorTest.java EnumValidatorTest.java FileValidatorTest.java Log: Added validator test cases for Enum File Url and an additional test for Number Revision ChangesPath No revision No revision 1.1.2.7 +14 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/Attic/NumberValidatorTest.java Index: NumberValidatorTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/Attic/NumberValidatorTest.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- NumberValidatorTest.java 26 Mar 2004 00:24:56 - 1.1.2.6 +++ NumberValidatorTest.java 20 Apr 2004 23:18:58 - 1.1.2.7 @@ -100,6 +100,20 @@ assertFalse(i.hasNext()); } +public void testValidate_ExcessChars() throws InvalidArgumentException { +final Object[] array = new Object[] { 10DowningStreet}; +final List list = Arrays.asList(array); +final Validator validator = NumberValidator.getIntegerInstance(); + +try{ +validator.validate(list); +fail(InvalidArgumentException); +} +catch(InvalidArgumentException e){ +assertEquals(10DowningStreet,e.getMessage()); +} +} + public void testValidate_Maximum() { final Object[] array = new Object[] { 1, 107 }; final List list = Arrays.asList(array); No revision Index: NumberValidatorTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/Attic/NumberValidatorTest.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- NumberValidatorTest.java 26 Mar 2004 00:24:56 - 1.1.2.6 +++ NumberValidatorTest.java 20 Apr 2004 23:18:58 - 1.1.2.7 @@ -100,6 +100,20 @@ assertFalse(i.hasNext()); } +public void testValidate_ExcessChars() throws InvalidArgumentException { +final Object[] array = new Object[] { 10DowningStreet}; +final List list = Arrays.asList(array); +final Validator validator = NumberValidator.getIntegerInstance(); + +try{ +validator.validate(list); +fail(InvalidArgumentException); +} +catch(InvalidArgumentException e){ +assertEquals(10DowningStreet,e.getMessage()); +} +} + public void testValidate_Maximum() { final Object[] array = new Object[] { 1, 107 }; final List list = Arrays.asList(array); No revision Index: NumberValidatorTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/Attic/NumberValidatorTest.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- NumberValidatorTest.java 26 Mar 2004 00:24:56 - 1.1.2.6 +++ NumberValidatorTest.java 20 Apr 2004 23:18:58 - 1.1.2.7 @@ -100,6 +100,20 @@ assertFalse(i.hasNext()); } +public void testValidate_ExcessChars() throws InvalidArgumentException { +final Object[] array = new Object[] { 10DowningStreet}; +final List list = Arrays.asList(array); +final Validator validator = NumberValidator.getIntegerInstance(); + +try{ +validator.validate(list); +fail(InvalidArgumentException); +} +catch(InvalidArgumentException e){ +assertEquals(10DowningStreet,e.getMessage()); +} +} + public void testValidate_Maximum() { final Object[] array = new Object[] { 1, 107 }; final List list = Arrays.asList(array); 1.1.2.1 +55 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/Attic/UrlValidatorTest.java 1.1.2.1 +58 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/Attic/EnumValidatorTest.java 1.1.2.1 +82 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/validation/Attic/FileValidatorTest.java - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli2/bug Bug28005Test.java
roxspring2004/04/19 14:35:11 Modified:cli/src/java/org/apache/commons/cli2/option Tag: RESEARCH_CLI_2_ROXSPRING GroupImpl.java Added: cli/src/test/org/apache/commons/cli2/bug Tag: RESEARCH_CLI_2_ROXSPRING Bug28005Test.java Log: Identified and removed infinite loop condition when processing anonymous arguments PR:28005 Revision ChangesPath No revision No revision 1.1.2.3 +6 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/GroupImpl.java Index: GroupImpl.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/option/Attic/GroupImpl.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- GroupImpl.java14 Apr 2004 18:31:16 - 1.1.2.2 +++ GroupImpl.java19 Apr 2004 21:35:10 - 1.1.2.3 @@ -193,6 +193,12 @@ // move iterator back, current value not used arguments.previous(); +// if there are no anonymous arguments then this group can't +// process the argument +if(anonymous.isEmpty()){ +break; +} + // TODO: why do we iterate over all anonymous arguments? // canProcess will always return true? for (final Iterator i = anonymous.iterator(); i.hasNext();) { No revision No revision 1.1.2.1 +79 -0 jakarta-commons/cli/src/test/org/apache/commons/cli2/bug/Attic/Bug28005Test.java - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli HelpFormatter.java
roxspring2004/04/19 15:09:51 Modified:cli/src/test/org/apache/commons/cli Tag: RESEARCH_CLI_2_ROXSPRING TestHelpFormatter.java cli/src/java/org/apache/commons/cli Tag: RESEARCH_CLI_2_ROXSPRING HelpFormatter.java Log: HelpFormatter now uses predictable sorting, previously: it simply compares the object's toString() values rather than using the getKey() method which would perform the sort that the comments seem to indicate is desired Also brought TestHelpFormatter expectations in line. PR:24184 Submitted by: Robert Fletcher [EMAIL PROTECTED] Revision ChangesPath No revision No revision 1.6.4.3 +1 -1 jakarta-commons/cli/src/test/org/apache/commons/cli/TestHelpFormatter.java Index: TestHelpFormatter.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/TestHelpFormatter.java,v retrieving revision 1.6.4.2 retrieving revision 1.6.4.3 diff -u -r1.6.4.2 -r1.6.4.3 --- TestHelpFormatter.java4 Feb 2004 02:01:53 - 1.6.4.2 +++ TestHelpFormatter.java19 Apr 2004 22:09:50 - 1.6.4.3 @@ -165,7 +165,7 @@ assertEquals(simple auto usage, expected, out.toString().trim()); out.reset(); - expected = usage: app [-b] [-a]; + expected = usage: app [-a] [-b]; options = new Options().addOption(a, false, ) .addOption(b, false, bbb ); hf.printUsage( pw, 60, app, options ); No revision No revision 1.14.2.3 +8 -29 jakarta-commons/cli/src/java/org/apache/commons/cli/HelpFormatter.java Index: HelpFormatter.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/HelpFormatter.java,v retrieving revision 1.14.2.2 retrieving revision 1.14.2.3 diff -u -r1.14.2.2 -r1.14.2.3 --- HelpFormatter.java4 Feb 2004 02:01:50 - 1.14.2.2 +++ HelpFormatter.java19 Apr 2004 22:09:51 - 1.14.2.3 @@ -657,7 +657,7 @@ Option option; List optList = options.helpOptions(); -Collections.sort(optList, new StringBufferComparator()); +Collections.sort(optList, new OptionComparator()); for (Iterator i = optList.iterator(); i.hasNext();) { @@ -885,9 +885,9 @@ // -- Inner classes /** * pThis class implements the codeComparator/code interface - * for comparing StringBuffers./p + * for comparing Options./p */ -private static class StringBufferComparator +private static class OptionComparator implements Comparator { /** @@ -895,8 +895,8 @@ * integer, zero, or a positive integer as the first argument * is less than, equal to, or greater than the second./p * - * @param o1 The first StringBuffer to be compared. - * @param o2 The second StringBuffer to be compared. + * @param o1 The first Option to be compared. + * @param o2 The second Option to be compared. * * @return a negative integer, zero, or a positive integer as * the first argument is less than, equal to, or greater than the @@ -904,31 +904,10 @@ */ public int compare(Object o1, Object o2) { -String str1 = stripPrefix(o1.toString()); -String str2 = stripPrefix(o2.toString()); +Option opt1 = (Option)o1; +Option opt2 = (Option)o2; -return (str1.compareTo(str2)); -} - -/** - * pRemoves any leading hyphens from codestrOption/code./p - * - * @param strOption The String from which to strip the leading - * hyphens. - * - * @return The String without any leading hyphens. - */ -private String stripPrefix(String strOption) -{ -// Strip any leading '-' characters -int iStartIndex = strOption.lastIndexOf('-'); - -if (iStartIndex == -1) -{ -iStartIndex = 0; -} - -return strOption.substring(iStartIndex); +return opt1.getKey().compareToIgnoreCase(opt2.getKey()); } } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli project.xml
roxspring2004/04/19 15:11:48 Modified:cli Tag: RESEARCH_CLI_2_ROXSPRING project.xml Log: HelpFormatter now uses predictable sorting, previously: it simply compares the object's toString() values rather than using the getKey() method which would perform the sort that the comments seem to indicate is desired Also brought TestHelpFormatter expectations in line. PR:24184 Submitted by: Robert Fletcher [EMAIL PROTECTED] Revision ChangesPath No revision No revision 1.16.2.8 +1 -0 jakarta-commons/cli/project.xml Index: project.xml === RCS file: /home/cvs/jakarta-commons/cli/project.xml,v retrieving revision 1.16.2.7 retrieving revision 1.16.2.8 diff -u -r1.16.2.7 -r1.16.2.8 --- project.xml 13 Apr 2004 21:56:03 - 1.16.2.7 +++ project.xml 19 Apr 2004 22:11:47 - 1.16.2.8 @@ -104,6 +104,7 @@ !-- Unit test classes -- unitTest includes +include**/Test*.java/include include**/*Test.java/include /includes /unitTest - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli Parser.java
roxspring2004/04/19 16:55:40 Modified:cli/src/java/org/apache/commons/cli Tag: RESEARCH_CLI_2_ROXSPRING Parser.java Log: Missing option error message improvement PR:23218 Submitted by: Marcus Crafter [EMAIL PROTECTED] Revision ChangesPath No revision No revision 1.13.2.3 +2 -2 jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java Index: Parser.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Parser.java,v retrieving revision 1.13.2.2 retrieving revision 1.13.2.3 diff -u -r1.13.2.2 -r1.13.2.3 --- Parser.java 4 Feb 2004 02:01:50 - 1.13.2.2 +++ Parser.java 19 Apr 2004 23:55:40 - 1.13.2.3 @@ -346,7 +346,7 @@ if ((opt.getValues() == null) !opt.hasOptionalArg()) { -throw new MissingArgumentException(no argument for: +throw new MissingArgumentException(Missing argument for option: + opt.getKey()); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/util HelpFormatter.java
roxspring2004/04/14 11:25:44 Modified:cli/src/test/org/apache/commons/cli2/util Tag: RESEARCH_CLI_2_ROXSPRING HelpFormatterTest.java cli/src/java/org/apache/commons/cli2/util Tag: RESEARCH_CLI_2_ROXSPRING HelpFormatter.java Log: HelpFormatter print methods now use the member PrintWriter rather than a parameter Revision ChangesPath No revision No revision 1.1.2.3 +14 -8 jakarta-commons/cli/src/test/org/apache/commons/cli2/util/Attic/HelpFormatterTest.java Index: HelpFormatterTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/util/Attic/HelpFormatterTest.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- HelpFormatterTest.java1 Apr 2004 21:13:36 - 1.1.2.2 +++ HelpFormatterTest.java14 Apr 2004 18:25:43 - 1.1.2.3 @@ -136,8 +136,8 @@ public void testPrintHelp() throws IOException { final StringWriter writer = new StringWriter(); -helpFormatter.printHelp(new PrintWriter(writer)); -//System.out.println(writer); +helpFormatter.setPrintWriter(new PrintWriter(writer)); +helpFormatter.printHelp(); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); assertEquals( @@ -172,8 +172,9 @@ public void testPrintHelp_WithException() throws IOException { final StringWriter writer = new StringWriter(); +helpFormatter.setPrintWriter(new PrintWriter(writer)); helpFormatter.setException(new OptionException(verbose)); -helpFormatter.printHelp(new PrintWriter(writer)); +helpFormatter.printHelp(); //System.out.println(writer); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); @@ -191,8 +192,9 @@ public void testPrintException() throws IOException { final StringWriter writer = new StringWriter(); +helpFormatter.setPrintWriter(new PrintWriter(writer)); helpFormatter.setException(new OptionException(verbose, cli.error.missing.option)); -helpFormatter.printException(new PrintWriter(writer)); +helpFormatter.printException(); //System.out.println(writer); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); @@ -207,7 +209,8 @@ public void testPrintUsage() throws IOException { final StringWriter writer = new StringWriter(); -helpFormatter.printUsage(new PrintWriter(writer)); +helpFormatter.setPrintWriter(new PrintWriter(writer)); +helpFormatter.printUsage(); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); assertEquals( @@ -227,7 +230,8 @@ public void testPrintHeader() throws IOException { final StringWriter writer = new StringWriter(); -helpFormatter.printHeader(new PrintWriter(writer)); +helpFormatter.setPrintWriter(new PrintWriter(writer)); +helpFormatter.printHeader(); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); assertEquals( @@ -241,7 +245,8 @@ public void testPrintFooter() throws IOException { final StringWriter writer = new StringWriter(); -helpFormatter.printFooter(new PrintWriter(writer)); +helpFormatter.setPrintWriter(new PrintWriter(writer)); +helpFormatter.printFooter(); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); assertEquals( @@ -258,7 +263,8 @@ public void testPrintDivider() throws IOException { final StringWriter writer = new StringWriter(); -helpFormatter.printDivider(new PrintWriter(writer)); +helpFormatter.setPrintWriter(new PrintWriter(writer)); +helpFormatter.printDivider(); final BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); assertEquals( No revision No revision 1.1.2.2 +158 -59 jakarta-commons/cli/src/java/org/apache/commons/cli2/util/Attic/HelpFormatter.java Index: HelpFormatter.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/util/Attic/HelpFormatter.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- HelpFormatter.java31 Mar 2004 00:50:45 - 1.1.2.1
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli CLI2Converter.java
roxspring2004/04/14 11:31:17 Modified:cli/src/java/org/apache/commons/cli2 Tag: RESEARCH_CLI_2_ROXSPRING Argument.java DisplaySetting.java Group.java WriteableCommandLine.java Parent.java HelpLine.java Option.java OptionException.java CommandLine.java cli/src/java/org/apache/commons/cli2/commandline Tag: RESEARCH_CLI_2_ROXSPRING PreferencesCommandLine.java CommandLineImpl.java DefaultingCommandLine.java PropertiesCommandLine.java Parser.java WriteableCommandLineImpl.java cli/src/java/org/apache/commons/cli2/validation Tag: RESEARCH_CLI_2_ROXSPRING DateValidator.java NumberValidator.java UrlValidator.java InvalidArgumentException.java Validator.java FileValidator.java ClassValidator.java cli/src/java/org/apache/commons/cli2/option Tag: RESEARCH_CLI_2_ROXSPRING GroupImpl.java Command.java DefaultOption.java ParentImpl.java ArgumentImpl.java Switch.java OptionImpl.java PropertyOption.java SourceDestArgument.java cli/src/java/org/apache/commons/cli2/builder Tag: RESEARCH_CLI_2_ROXSPRING GroupBuilder.java SwitchBuilder.java ArgumentBuilder.java DefaultOptionBuilder.java PatternBuilder.java CommandBuilder.java cli/src/java/org/apache/commons/cli2/resource Tag: RESEARCH_CLI_2_ROXSPRING ResourceHelper.java cli/src/java/org/apache/commons/cli2/util Tag: RESEARCH_CLI_2_ROXSPRING Comparators.java cli/src/java/org/apache/commons/cli Tag: RESEARCH_CLI_2_ROXSPRING CLI2Converter.java Log: Grand Javadoc patch: public classes have at least minimal javadocs public and protected methods are documented where defined (overrides have not been explicitly documented) public and protected attributes are documented Revision ChangesPath No revision No revision 1.1.2.6 +0 -2 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Argument.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Argument.java.diff?r1=1.1.2.5r2=1.1.2.6 1.1.2.2 +77 -3 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/DisplaySetting.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/DisplaySetting.java.diff?r1=1.1.2.1r2=1.1.2.2 1.1.2.5 +9 -4 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Group.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Group.java.diff?r1=1.1.2.4r2=1.1.2.5 1.1.2.4 +38 -3 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/WriteableCommandLine.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/WriteableCommandLine.java.diff?r1=1.1.2.3r2=1.1.2.4 1.1.2.6 +14 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Parent.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Parent.java.diff?r1=1.1.2.5r2=1.1.2.6 1.1.2.6 +3 -0 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/HelpLine.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/HelpLine.java.diff?r1=1.1.2.5r2=1.1.2.6 1.1.2.11 +25 -3 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Option.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/Option.java.diff?r1=1.1.2.10r2=1.1.2.11 1.1.2.8 +31 -14 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionException.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionException.java.diff?r1=1.1.2.7r2=1.1.2.8 1.1.2.10 +170 -6 jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/CommandLine.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/CommandLine.java.diff?r1=1.1.2.9r2=1.1.2.10 No revision No revision 1.1.2.3 +38 -24 jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/PreferencesCommandLine.java http://cvs.apache.org/viewcvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/PreferencesCommandLine.java.diff?r1=1.1.2.2r2=1.1.2.3 1.1.2.8 +0 -2 jakarta
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli CommandLine.java Option.java Options.java package.html OptionBuilder.java
roxspring2004/04/14 12:32:18 Modified:cli/src/java/org/apache/commons/cli Tag: RESEARCH_CLI_2_ROXSPRING CommandLine.java Option.java Options.java package.html OptionBuilder.java Log: Another Javadoc patch: dropped html paragraph formatting from html comments to deal with -breakiterator javadoc warnings Revision ChangesPath No revision No revision 1.18.2.3 +18 -18 jakarta-commons/cli/src/java/org/apache/commons/cli/CommandLine.java Index: CommandLine.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/CommandLine.java,v retrieving revision 1.18.2.2 retrieving revision 1.18.2.3 diff -u -r1.18.2.2 -r1.18.2.3 --- CommandLine.java 4 Feb 2004 02:01:50 - 1.18.2.2 +++ CommandLine.java 14 Apr 2004 19:32:18 - 1.18.2.3 @@ -55,14 +55,14 @@ private Option[] optionsArray; /** - * pCreates a command line./p + * Creates a command line. */ CommandLine() { } /** - * pQuery to see if an option has been set./p + * Query to see if an option has been set. * * @param opt Short name of the option * @return true if set, false if not @@ -73,7 +73,7 @@ } /** - * pQuery to see if an option has been set./p + * Query to see if an option has been set. * * @param opt character name of the option * @return true if set, false if not @@ -84,7 +84,7 @@ } /** - * pReturn the codeObject/code type of this codeOption/code./p + * Return the codeObject/code type of this codeOption/code. * * @param opt the name of the option * @return the type of this codeOption/code @@ -104,7 +104,7 @@ } /** - * pReturn the codeObject/code type of this codeOption/code./p + * Return the codeObject/code type of this codeOption/code. * * @param opt the name of the option * @return the type of opt @@ -115,7 +115,7 @@ } /** - * pRetrieve the argument, if any, of this option./p + * Retrieve the argument, if any, of this option. * * @param opt the name of the option * @return Value of the argument if option is set, and has an argument, @@ -129,7 +129,7 @@ } /** - * pRetrieve the argument, if any, of this option./p + * Retrieve the argument, if any, of this option. * * @param opt the character name of the option * @return Value of the argument if option is set, and has an argument, @@ -141,7 +141,7 @@ } /** - * pRetrieves the array of values, if any, of an option./p + * Retrieves the array of values, if any, of an option. * * @param opt string name of the option * @return Values of the argument if option is set, and has an argument, @@ -169,7 +169,7 @@ } /** - * pRetrieves the array of values, if any, of an option./p + * Retrieves the array of values, if any, of an option. * * @param opt character name of the option * @return Values of the argument if option is set, and has an argument, @@ -181,7 +181,7 @@ } /** - * pRetrieve the argument, if any, of an option./p + * Retrieve the argument, if any, of an option. * * @param opt name of the option * @param defaultValue is the default value to be returned if the option @@ -197,7 +197,7 @@ } /** - * pRetrieve the argument, if any, of an option./p + * Retrieve the argument, if any, of an option. * * @param opt character name of the option * @param defaultValue is the default value to be returned if the option @@ -211,7 +211,7 @@ } /** - * pRetrieve any left-over non-recognized options and arguments/p + * Retrieve any left-over non-recognized options and arguments * * @return remaining items passed in but not parsed as an array */ @@ -225,7 +225,7 @@ } /** - * pRetrieve any left-over non-recognized options and arguments/p + * Retrieve any left-over non-recognized options and arguments * * @return remaining items passed in but not parsed as a codeList/code. */ @@ -257,7 +257,7 @@ */ /** - * pAdd left-over unrecognized option/argument./p + * Add left-over unrecognized option/argument. * * @param arg the unrecognised option/argument. */ @@ -267,8 +267,8 @@ } /** - * pAdd an option to the command line. The values of - * the option are stored./p
cvs commit: jakarta-commons/cli maven.xml
roxspring2004/04/13 18:11:58 Added: cli Tag: RESEARCH_CLI_2_ROXSPRING maven.xml Log: My bad - a cut down version was needed afterall Revision ChangesPath No revision No revision 1.1.6.2 +15 -3 jakarta-commons/cli/maven.xml - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli CLI2ConverterTest.java
roxspring2004/04/08 08:56:14 Modified:cli/src/java/org/apache/commons/cli Tag: RESEARCH_CLI_2_ROXSPRING CLI2Converter.java cli/src/test/org/apache/commons/cli Tag: RESEARCH_CLI_2_ROXSPRING CLI2ConverterTest.java Log: Grand package renaming: .builders - .builder .impl - option .resources - .resource .apps - .application .bugs - .bug Revision ChangesPath No revision No revision 1.1.2.3 +4 -4 jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/CLI2Converter.java Index: CLI2Converter.java === RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/CLI2Converter.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- CLI2Converter.java30 Mar 2004 01:46:11 - 1.1.2.2 +++ CLI2Converter.java8 Apr 2004 15:56:14 - 1.1.2.3 @@ -23,10 +23,10 @@ import org.apache.commons.cli2.Group; import org.apache.commons.cli2.Option; -import org.apache.commons.cli2.builders.ArgumentBuilder; -import org.apache.commons.cli2.builders.DefaultOptionBuilder; -import org.apache.commons.cli2.builders.GroupBuilder; -import org.apache.commons.cli2.impl.GroupImpl; +import org.apache.commons.cli2.builder.ArgumentBuilder; +import org.apache.commons.cli2.builder.DefaultOptionBuilder; +import org.apache.commons.cli2.builder.GroupBuilder; +import org.apache.commons.cli2.option.GroupImpl; import org.apache.commons.cli2.validation.InvalidArgumentException; import org.apache.commons.cli2.validation.Validator; No revision No revision 1.1.2.3 +2 -2 jakarta-commons/cli/src/test/org/apache/commons/cli/Attic/CLI2ConverterTest.java Index: CLI2ConverterTest.java === RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/Attic/CLI2ConverterTest.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- CLI2ConverterTest.java30 Mar 2004 01:46:11 - 1.1.2.2 +++ CLI2ConverterTest.java8 Apr 2004 15:56:14 - 1.1.2.3 @@ -16,8 +16,8 @@ package org.apache.commons.cli; import org.apache.commons.cli2.Group; -import org.apache.commons.cli2.builders.PatternBuilder; -import org.apache.commons.cli2.impl.GroupImpl; +import org.apache.commons.cli2.builder.PatternBuilder; +import org.apache.commons.cli2.option.GroupImpl; import junit.framework.TestCase; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/images util.svg commandlines.svg diagrams.css diagrams.js diagrams-cli2.js options.svg
roxspring2004/04/04 16:42:27 Added: cli/xdocs/images Tag: RESEARCH_CLI_2_ROXSPRING util.svg commandlines.svg diagrams.css diagrams.js diagrams-cli2.js options.svg Log: Added some svg/js/css diagrams Revision ChangesPath No revision No revision 1.1.2.1 +46 -0 jakarta-commons/cli/xdocs/images/Attic/util.svg 1.1.2.1 +56 -0 jakarta-commons/cli/xdocs/images/Attic/commandlines.svg 1.1.2.1 +64 -0 jakarta-commons/cli/xdocs/images/Attic/diagrams.css 1.1.2.1 +367 -0jakarta-commons/cli/xdocs/images/Attic/diagrams.js 1.1.2.1 +128 -0jakarta-commons/cli/xdocs/images/Attic/diagrams-cli2.js 1.1.2.1 +65 -0 jakarta-commons/cli/xdocs/images/Attic/options.svg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/xdocs/images commandlines.png options.png
roxspring2004/04/04 16:44:08 Added: cli/xdocs/images Tag: RESEARCH_CLI_2_ROXSPRING commandlines.png options.png Log: Added pngs of diagrams for now (waiting for maven-svg plugin) Created using: java -jar /path/to/batik-rasterizer.jar -onload *.svg Revision ChangesPath No revision No revision 1.1.2.1 +56 -0 jakarta-commons/cli/xdocs/images/Attic/commandlines.png Binary file 1.1.2.1 +64 -0 jakarta-commons/cli/xdocs/images/Attic/options.png Binary file - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/builder - New directory
roxspring2004/04/01 13:12:57 jakarta-commons/cli/src/java/org/apache/commons/cli2/builder - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]