Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #8 from penSecIT/master

Modifications required by Sonatype
  • Loading branch information...
commit 37432a3e50216177ac6ca004fe7aa7c631795243 2 parents e54537c + 103dd0f
Steve Purcell authored
2  README.md
View
@@ -39,7 +39,7 @@ To compile, package, and test the code, run either
or
- mvn clean package javadoc:javadoc jar:test-jar
+ mvn clean package source:jar javadoc:jar jar:test-jar
Two jars are created, one called `target/jargs-$VERSION$.jar`, which contains
the runtime library, and one called `target/jargs-$VERSION$-tests.jar`, which
18 build.xml
View
@@ -114,6 +114,24 @@
</java>
</target>
+ <target name="run-examples" depends="compile-examples">
+ <java classname="com.sanityinc.jargs.examples.OptionTest"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ </java>
+ <java classname="com.sanityinc.jargs.examples.AutoHelpParser"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ <arg value="--help" />
+ </java>
+ <java classname="com.sanityinc.jargs.examples.CustomOptionTest"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ <arg value="-d" />
+ <arg value="09/23/2012" />
+ </java>
+ <java classname="com.sanityinc.jargs.examples.OptionParserSubclassTest"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ </java>
+ </target>
+
<target name="clean"
description="Remove all generated files.">
<delete dir="target" />
30 pom.xml
View
@@ -35,6 +35,12 @@
<project>
<modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.sonatype.oss</groupId>
+ <artifactId>oss-parent</artifactId>
+ <version>7</version>
+ </parent>
+
<groupId>com.sanityinc</groupId>
<artifactId>jargs</artifactId>
<version>2.0-SNAPSHOT</version>
@@ -56,6 +62,30 @@
</license>
</licenses>
+ <scm>
+ <connection>scm:git:git@github.com:purcell/jargs.git</connection>
+ <developerConnection>scm:git:git@github.com:purcell/jargs.git</developerConnection>
+ <url>git@github.com:purcell/jargs.git</url>
+ </scm>
+
+ <developers>
+ <developer>
+ <name>Steve Purcell</name>
+ </developer>
+ <developer>
+ <name>Vidar Holen</name>
+ </developer>
+ <developer>
+ <name>Michal Ceresna</name>
+ </developer>
+ <developer>
+ <name>Ewan Mellor</name>
+ </developer>
+ <developer>
+ <name>penSec.IT UG (haftungsbeschränkt)</name>
+ </developer>
+ </developers>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
11 src/examples/java/com/sanityinc/jargs/examples/AutoHelpParser.java
View
@@ -35,7 +35,6 @@
import com.sanityinc.jargs.CmdLineParser;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
@@ -83,7 +82,7 @@ public static void main( String[] args ) {
System.exit(2);
}
- if ( Boolean.TRUE.equals(parser.getOptionValue(help))) {
+ if ( parser.getOptionValue(help) ) {
parser.printUsage();
System.exit(0);
}
@@ -91,10 +90,10 @@ public static void main( String[] args ) {
// Extract the values entered for the various options -- if the
// options were not specified, the corresponding values will be
// null.
- Boolean verboseValue = (Boolean)parser.getOptionValue(verbose);
- Integer sizeValue = (Integer)parser.getOptionValue(size);
- String nameValue = (String)parser.getOptionValue(name);
- Double fractionValue = (Double)parser.getOptionValue(fraction);
+ Boolean verboseValue = parser.getOptionValue(verbose);
+ Integer sizeValue = parser.getOptionValue(size);
+ String nameValue = parser.getOptionValue(name);
+ Double fractionValue = parser.getOptionValue(fraction);
// For testing purposes, we just print out the option values
System.out.println("verbose: " + verboseValue);
6 src/examples/java/com/sanityinc/jargs/examples/OptionParserSubclassTest.java
View
@@ -88,9 +88,9 @@ public static void main( String[] args ) {
MyOptionsParser.FRACTION
};
- for ( int j = 0; j<allOptions.length; ++j ) {
- System.out.println(allOptions[j].longForm() + ": " +
- myOptions.getOptionValue(allOptions[j]));
+ for ( CmdLineParser.Option<?> option : allOptions ) {
+ System.out.println(option.longForm() + ": " +
+ myOptions.getOptionValue(option));
}
String[] otherArgs = myOptions.getRemainingArgs();
1  src/examples/java/com/sanityinc/jargs/examples/OptionTest.java
View
@@ -36,7 +36,6 @@
import com.sanityinc.jargs.CmdLineParser.Option;
import java.util.Collection;
-import java.util.Iterator;
public class OptionTest {
15 src/main/java/com/sanityinc/jargs/CmdLineParser.java
View
@@ -40,7 +40,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Vector;
/**
* Largely GNU-compatible command-line options parser. Has short (-v) and
@@ -507,13 +506,7 @@ protected String parseValue( String arg, Locale locale ) {
* list of command-line arguments. The default locale is used for
* parsing options whose values might be locale-specific.
*/
- public final void parse( String[] argv )
- throws IllegalOptionValueException, UnknownOptionException {
-
- // It would be best if this method only threw OptionException, but for
- // backwards compatibility with old user code we throw the two
- // exceptions above instead.
-
+ public final void parse( String[] argv ) throws OptionException {
parse(argv, Locale.getDefault());
}
@@ -523,11 +516,7 @@ public final void parse( String[] argv )
* parsing options whose values might be locale-specific.
*/
public final void parse( String[] argv, Locale locale )
- throws IllegalOptionValueException, UnknownOptionException {
-
- // It would be best if this method only threw OptionException, but for
- // backwards compatibility with old user code we throw the two
- // exceptions above instead.
+ throws OptionException {
ArrayList<Object> otherArgs = new ArrayList<Object>();
int position = 0;
5 src/test/java/com/sanityinc/jargs/CmdLineParserTestCase.java
View
@@ -35,7 +35,6 @@
import com.sanityinc.jargs.CmdLineParser.Option;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Locale;
import static org.junit.Assert.assertEquals;
@@ -203,9 +202,7 @@ public void testGetOptionValues() throws Exception {
int verbosity = 0;
Collection<Boolean> v = parser.getOptionValues(verbose);
- Iterator<Boolean> it = v.iterator();
- while (it.hasNext()) {
- Boolean b = it.next();
+ for (Boolean b : v) {
if (b == Boolean.TRUE) {
verbosity++;
Please sign in to comment.
Something went wrong with that request. Please try again.