Testing out another command parser.
This one seems like it will be good, but there appears to be a bug with it sadly. https://github.com/lexicalscope/jewelcli/issues/28
This commit is contained in:
parent
b9f01dd599
commit
e078f73d3c
6
pom.xml
6
pom.xml
@ -73,6 +73,12 @@
|
|||||||
<version>1.32</version>
|
<version>1.32</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lexicalscope.jewelcli</groupId>
|
||||||
|
<artifactId>jewelcli</artifactId>
|
||||||
|
<version>0.8.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Start of Test Dependencies -->
|
<!-- Start of Test Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.graywolf336.jail.command.jewel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.lexicalscope.jewel.cli.Option;
|
||||||
|
|
||||||
|
public interface Jailing {
|
||||||
|
@Option(shortName={"player", "pl", "p"})
|
||||||
|
String getPlayer();
|
||||||
|
|
||||||
|
@Option(shortName="c")
|
||||||
|
String getCell();
|
||||||
|
|
||||||
|
@Option(shortName="r")
|
||||||
|
List<String> getReason();
|
||||||
|
}
|
28
src/test/java/test/java/com/graywolf336/jail/TestJewel.java
Normal file
28
src/test/java/test/java/com/graywolf336/jail/TestJewel.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package test.java.com.graywolf336.jail;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.graywolf336.jail.command.jewel.Jailing;
|
||||||
|
import com.lexicalscope.jewel.cli.CliFactory;
|
||||||
|
|
||||||
|
public class TestJewel {
|
||||||
|
@Test
|
||||||
|
public void testJewel() {
|
||||||
|
String[] args = { "--player", "graywolf336", "-c", "testing", "-r", "This", "is", "a", "reason" };
|
||||||
|
Jailing j = CliFactory.parseArguments(Jailing.class, args);
|
||||||
|
|
||||||
|
Assert.assertEquals("graywolf336", j.getPlayer());
|
||||||
|
Assert.assertEquals("testing", j.getCell());
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for(String s : j.getReason()) {
|
||||||
|
sb.append(s).append(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
|
|
||||||
|
Assert.assertEquals("This is a reason", sb.toString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user