Package net.sourceforge.argparse4j.inf

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


    @Test
    public void testParseArgsWithSubparsers() throws ArgumentParserException {
        ap.addArgument("-f");
        Subparsers subparsers = ap.addSubparsers();
        Subparser parserA = subparsers.addParser("install");
        parserA.addArgument("pkg1");
        parserA.setDefault("func", "install");
        Subparser parserB = subparsers.addParser("search");
        parserB.addArgument("pkg2");
        parserB.setDefault("func", "search");
        Namespace res = ap.parseArgs("install aria2".split(" "));
View Full Code Here


        Subparsers subparsers = ap.addSubparsers();
        Subparser parserA = subparsers.addParser("install");
        parserA.addArgument("pkg1");
        parserA.setDefault("func", "install");
        Subparser parserB = subparsers.addParser("search");
        parserB.addArgument("pkg2");
        parserB.setDefault("func", "search");
        Namespace res = ap.parseArgs("install aria2".split(" "));
        assertEquals("aria2", res.get("pkg1"));
        assertEquals("install", res.get("func"));
    }
View Full Code Here

        assertEquals(String.format(
                TextHelper.LOCALE_ROOT,
                "usage: argparse4j [-h] [-a A] -b B (-c C | -d D) file%n"),
                ap.formatUsage());
        Subparser foosub = ap.addSubparsers().addParser("foo");
        foosub.addArgument("hash");
        assertEquals(String.format(
                TextHelper.LOCALE_ROOT,
                "usage: argparse4j [-h] [-a A] -b B (-c C | -d D) file {foo} ...%n"),
                ap.formatUsage());
        assertEquals(String.format(
View Full Code Here

        ap.addArgument("s");
        ap.addArgument("t");
        ap.addArgument("u").help(Arguments.SUPPRESS);
        Subparsers subparsers = ap.addSubparsers();
        Subparser sap = subparsers.addParser("add");
        sap.addArgument("-i").help(Arguments.SUPPRESS);
        sap.addArgument("-j");

        assertEquals(String.format(
                     TextHelper.LOCALE_ROOT,
                     "usage: argparse4j [-h] [--foo FOO] [-b B] [-d D] (-f F | -g G) s t {add}%n"
View Full Code Here

        ap.addArgument("t");
        ap.addArgument("u").help(Arguments.SUPPRESS);
        Subparsers subparsers = ap.addSubparsers();
        Subparser sap = subparsers.addParser("add");
        sap.addArgument("-i").help(Arguments.SUPPRESS);
        sap.addArgument("-j");

        assertEquals(String.format(
                     TextHelper.LOCALE_ROOT,
                     "usage: argparse4j [-h] [--foo FOO] [-b B] [-d D] (-f F | -g G) s t {add}%n"
                   + "                  ...%n"
View Full Code Here

        ap.addArgument("--bar");
        Subparsers subparsers = ap.addSubparsers();
        Subparser parser = subparsers.addParser("install");
        parser.description("This is sub-command of argparser4j.").epilog(
                "This is epilog of sub-command.");
        parser.addArgument("--foo");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j install [-h] [--foo FOO]%n"
                + "%n"
                + "This is sub-command of argparser4j.%n"
View Full Code Here

                .description( "Jolt CLI Diffy Tool. This tool will ingest two JSON inputs (from files or standard input) and " +
                        "perform the Jolt Diffy operation to detect any differences. The program will return an exit code of " +
                        "0 if no differences are found or a 1 if a difference is found or an error is encountered." )
                .defaultHelp( true );

        diffyParser.addArgument( "filePath1" ).help( "File path to feed to Input #1 for the Diffy operation. " +
                "This file should contain valid JSON." )
                .type( Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead() );
        diffyParser.addArgument( "filePath2" ).help( "File path to feed to Input #2 for the Diffy operation. " +
                "This file should contain valid JSON. " +
                "This argument is mutually exclusive with -i; one or the other should be specified." )
View Full Code Here

                .defaultHelp( true );

        diffyParser.addArgument( "filePath1" ).help( "File path to feed to Input #1 for the Diffy operation. " +
                "This file should contain valid JSON." )
                .type( Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead() );
        diffyParser.addArgument( "filePath2" ).help( "File path to feed to Input #2 for the Diffy operation. " +
                "This file should contain valid JSON. " +
                "This argument is mutually exclusive with -i; one or the other should be specified." )
                .type( Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead() )
                .nargs( "?" ).setDefault( (File) null );   // these last two method calls make filePath2 optional
View Full Code Here

                "This file should contain valid JSON. " +
                "This argument is mutually exclusive with -i; one or the other should be specified." )
                .type( Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead() )
                .nargs( "?" ).setDefault( (File) null );   // these last two method calls make filePath2 optional

        diffyParser.addArgument( "-s" ).help( "Diffy will suppress output and run silently." )
                .action( Arguments.storeTrue() );
        diffyParser.addArgument( "-a" ).help( "Diffy will not consider array order when detecting differences" )
                .action( Arguments.storeTrue() );
    }
View Full Code Here

                .type( Arguments.fileType().verifyExists().verifyIsFile().verifyCanRead() )
                .nargs( "?" ).setDefault( (File) null );   // these last two method calls make filePath2 optional

        diffyParser.addArgument( "-s" ).help( "Diffy will suppress output and run silently." )
                .action( Arguments.storeTrue() );
        diffyParser.addArgument( "-a" ).help( "Diffy will not consider array order when detecting differences" )
                .action( Arguments.storeTrue() );
    }

    /**
     * Process the Diffy Subcommand
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.