-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
boolean isName() does not seem to work as expected: trying to make an optional switch that takes an optional value. Leaving the value off throws an ArgumentValidationException. See testOptionalPresentNoValue in this Junit test.
import static org.junit.Assert.*;
import org.junit.Test;
import com.lexicalscope.jewel.cli.*;
public class JewelParseTest {
public interface TestOption {
@Option
String getName();
boolean isName();
}
@Test
public void testOptionalMissing() throws ArgumentValidationException {
final TestOption rv = CliFactory.parseArguments(TestOption.class);
System.out.println(rv.toString());
assertFalse(rv.isName());
assertNull(rv.getName());
}
@Test
public void testOptionalPresentNoValue()
throws ArgumentValidationException {
final TestOption rv = CliFactory.parseArguments(TestOption.class, "--name");
System.out.println(rv.toString());
assertTrue(rv.isName());
assertNull(rv.getName());
}
@Test
public void testOptionalPresentWithValue() throws ArgumentValidationException {
final TestOption rv = CliFactory.parseArguments(TestOption.class, "--name",
"value");
System.out.println(rv.toString());
assertTrue(rv.isName());
assertEquals(rv.getName(), "value");
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels