Package net.sourceforge.argparse4j.inf

Examples of net.sourceforge.argparse4j.inf.MutuallyExclusiveGroup.addArgument()


    }

    @Test
    public void testParseArgsWithMutexGroup() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex");
        group.addArgument("--foo");
        group.addArgument("--bar");
        Namespace res = ap.parseArgs("--foo bar".split(" "));
        assertEquals("bar", res.get("foo"));
    }
View Full Code Here


    @Test
    public void testParseArgsWithMutexGroup() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex");
        group.addArgument("--foo");
        group.addArgument("--bar");
        Namespace res = ap.parseArgs("--foo bar".split(" "));
        assertEquals("bar", res.get("foo"));
    }

    @Test
View Full Code Here

    }

    @Test
    public void testParseArgsWithMutexGroupDuplicate() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex");
        group.addArgument("--foo");
        group.addArgument("--bar");
        try {
            ap.parseArgs("--foo bar --bar baz".split(" "));
            fail();
        } catch(ArgumentParserException e) {
View Full Code Here

    @Test
    public void testParseArgsWithMutexGroupDuplicate() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex");
        group.addArgument("--foo");
        group.addArgument("--bar");
        try {
            ap.parseArgs("--foo bar --bar baz".split(" "));
            fail();
        } catch(ArgumentParserException e) {
            assertEquals("argument --bar: not allowed with argument --foo", e.getMessage());
View Full Code Here

    }

    @Test
    public void testParseArgsWithMutexGroupRequired() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("--foo");
        group.addArgument("--bar");
        Namespace res = ap.parseArgs("--foo bar".split(" "));
        assertEquals("bar", res.get("foo"));
    }
View Full Code Here

    @Test
    public void testParseArgsWithMutexGroupRequired() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("--foo");
        group.addArgument("--bar");
        Namespace res = ap.parseArgs("--foo bar".split(" "));
        assertEquals("bar", res.get("foo"));
    }

    @Test
View Full Code Here

    }

    @Test
    public void testParseArgsWithMutexGroupRequiredFail() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("--foo");
        group.addArgument("--bar");
        try {
            ap.parseArgs(new String []{});
            fail();
        } catch(ArgumentParserException e) {
View Full Code Here

    @Test
    public void testParseArgsWithMutexGroupRequiredFail() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("--foo");
        group.addArgument("--bar");
        try {
            ap.parseArgs(new String []{});
            fail();
        } catch(ArgumentParserException e) {
            assertEquals("one of the arguments --foo --bar is required", e.getMessage());
View Full Code Here

    }

    @Test
    public void testParseArgsWithMutexGroupConcatDuplicate() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("-a").action(Arguments.storeTrue());
        group.addArgument("-b").action(Arguments.storeTrue());
        ap.addArgument("-c").action(Arguments.storeTrue());
        try {
            ap.parseArgs("-acb".split(" "));
        } catch(ArgumentParserException e) {
View Full Code Here

    @Test
    public void testParseArgsWithMutexGroupConcatDuplicate() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("-a").action(Arguments.storeTrue());
        group.addArgument("-b").action(Arguments.storeTrue());
        ap.addArgument("-c").action(Arguments.storeTrue());
        try {
            ap.parseArgs("-acb".split(" "));
        } catch(ArgumentParserException e) {
            assertEquals("argument -b: not allowed with argument -a", e.getMessage());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.