We're going to be using jcommander for parsing of the commands.
http://jcommander.org/
This commit is contained in:
@ -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;
|
||||
}
|
Reference in New Issue
Block a user