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:
graywolf336 2014-02-10 16:42:59 -06:00
parent b9f01dd599
commit e078f73d3c
3 changed files with 50 additions and 0 deletions

View File

@ -72,6 +72,12 @@
<artifactId>jcommander</artifactId>
<version>1.32</version>
</dependency>
<dependency>
<groupId>com.lexicalscope.jewelcli</groupId>
<artifactId>jewelcli</artifactId>
<version>0.8.8</version>
</dependency>
<!-- Start of Test Dependencies -->
<dependency>

View File

@ -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();
}

View 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());
}
}