Package net.sourceforge.argparse4j.inf

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


    }

    @Test
    public void testParseArgsWithMutexGroupConcat() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("-a").action(Arguments.storeTrue());
        group.addArgument("-b").action(Arguments.storeTrue());
        ap.addArgument("-c");
        Namespace res = ap.parseArgs("-acfoo".split(" "));
        assertEquals(true, res.getBoolean("a"));
        assertEquals("foo", res.get("c"));
View Full Code Here


    @Test
    public void testParseArgsWithMutexGroupConcat() throws ArgumentParserException {
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("-a").action(Arguments.storeTrue());
        group.addArgument("-b").action(Arguments.storeTrue());
        ap.addArgument("-c");
        Namespace res = ap.parseArgs("-acfoo".split(" "));
        assertEquals(true, res.getBoolean("a"));
        assertEquals("foo", res.get("c"));
    }
View Full Code Here

    @Test
    public void testParseArgsWithMutualExclusiveGroupAndSuppressHelp()
            throws ArgumentParserException {
        MutuallyExclusiveGroup mutex1 = ap.addMutuallyExclusiveGroup("mutex1")
                .required(true);
        mutex1.addArgument("-a").help(Arguments.SUPPRESS);
        Argument b = mutex1.addArgument("-b");
        // Check the suppressed argument is not shown in the error message
        try {
            ap.parseArgs(new String[]{});
            fail();
View Full Code Here

    public void testParseArgsWithMutualExclusiveGroupAndSuppressHelp()
            throws ArgumentParserException {
        MutuallyExclusiveGroup mutex1 = ap.addMutuallyExclusiveGroup("mutex1")
                .required(true);
        mutex1.addArgument("-a").help(Arguments.SUPPRESS);
        Argument b = mutex1.addArgument("-b");
        // Check the suppressed argument is not shown in the error message
        try {
            ap.parseArgs(new String[]{});
            fail();
        } catch(ArgumentParserException e) {
View Full Code Here

                TextHelper.LOCALE_ROOT,
                "usage: argparse4j [-h]%n"), ap.formatUsage());
        ap.addArgument("-a");
        ap.addArgument("-b").required(true);
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("-c").required(true);
        group.addArgument("-d").required(true);
        ap.addArgument("file");
        assertEquals(String.format(
                TextHelper.LOCALE_ROOT,
                "usage: argparse4j [-h] [-a A] -b B (-c C | -d D) file%n"),
View Full Code Here

                "usage: argparse4j [-h]%n"), ap.formatUsage());
        ap.addArgument("-a");
        ap.addArgument("-b").required(true);
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("mutex").required(true);
        group.addArgument("-c").required(true);
        group.addArgument("-d").required(true);
        ap.addArgument("file");
        assertEquals(String.format(
                TextHelper.LOCALE_ROOT,
                "usage: argparse4j [-h] [-a A] -b B (-c C | -d D) file%n"),
                ap.formatUsage());
View Full Code Here

    public void testFormatHelpWithMutexGroup()
            throws ArgumentParserException {
        ap.description("This is argparser4j.").epilog("This is epilog.");
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("group1")
                .description("group1 description");
        group.addArgument("--foo");
        group.addArgument("--bar");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j [-h] [--foo FOO | --bar BAR]%n"
                + "%n"
View Full Code Here

            throws ArgumentParserException {
        ap.description("This is argparser4j.").epilog("This is epilog.");
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup("group1")
                .description("group1 description");
        group.addArgument("--foo");
        group.addArgument("--bar");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j [-h] [--foo FOO | --bar BAR]%n"
                + "%n"
                + "This is argparser4j.%n"
View Full Code Here

    @Test
    public void testFormatHelpWithMutexGroupWithoutTitleAndDescription()
            throws ArgumentParserException {
        ap.description("This is argparser4j.").epilog("This is epilog.");
        MutuallyExclusiveGroup group = ap.addMutuallyExclusiveGroup();
        group.addArgument("--foo");
        ap.addArgument("-b").action(Arguments.storeTrue());
        // Without title and description, options in mutually exclusive group
        // is merged into other optional arguments.
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
View Full Code Here

        group.addArgument("--foo");
        group.addArgument("--bar").help(Arguments.SUPPRESS);
        ap.addArgument("-a").help(Arguments.SUPPRESS).required(true);
        ap.addArgument("-b");
        MutuallyExclusiveGroup mutex1 = ap.addMutuallyExclusiveGroup("mutex1");
        mutex1.addArgument("-c").help(Arguments.SUPPRESS);
        mutex1.addArgument("-d");
        MutuallyExclusiveGroup mutex2 = ap.addMutuallyExclusiveGroup("mutex2")
                .required(true);
        mutex2.addArgument("-e").help(Arguments.SUPPRESS);
        mutex2.addArgument("-f");
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.