We're going to be using jcommander for parsing of the commands.
http://jcommander.org/
This commit is contained in:
parent
afccd42c24
commit
3b77efa93f
26
pom.xml
26
pom.xml
@ -67,6 +67,12 @@
|
|||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.beust</groupId>
|
||||||
|
<artifactId>jcommander</artifactId>
|
||||||
|
<version>1.30</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Start of Test Dependencies -->
|
<!-- Start of Test Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -147,6 +153,26 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>com.beust:jcommander</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package test.java.com.graywolf336.jail;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.beust.jcommander.JCommander;
|
||||||
|
|
||||||
|
import test.java.com.graywolf336.jail.util.JCommanderExample;
|
||||||
|
|
||||||
|
public class TestJCommander {
|
||||||
|
@Test
|
||||||
|
public void testIt() {
|
||||||
|
JCommanderExample jce = new JCommanderExample();
|
||||||
|
String[] args = { "-log", "2", "-groups", "unit" };
|
||||||
|
new JCommander(jce, args);
|
||||||
|
|
||||||
|
Assert.assertEquals(jce.verbose.intValue(), 2);
|
||||||
|
Assert.assertEquals(jce.groups.toLowerCase(), "unit");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package test.java.com.graywolf336.jail.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.beust.jcommander.Parameter;
|
||||||
|
|
||||||
|
public class JCommanderExample {
|
||||||
|
@Parameter
|
||||||
|
public List<String> parameters = new ArrayList<String>();
|
||||||
|
|
||||||
|
@Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity")
|
||||||
|
public Integer verbose = 1;
|
||||||
|
|
||||||
|
@Parameter(names = "-groups", description = "Comma-separated list of group names to be run")
|
||||||
|
public String groups;
|
||||||
|
|
||||||
|
@Parameter(names = "-debug", description = "Debug mode")
|
||||||
|
public boolean debug = false;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user