Examples of addParser()


Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    }

    @Test
    public void testParseArgsWithCommandAfterSeparator() throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers();
        subparsers.addParser("install");
        try {
            ap.parseArgs("-- install".split(" "));
            fail();
        } catch(ArgumentParserException e) {
            assertEquals("unrecognized arguments: 'install'", e.getMessage());
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    }

    @Test
    public void testParseArgsWithoutSubcommand() throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers();
        subparsers.addParser("install");
        try {
            ap.parseArgs(new String[]{});
            fail();
        } catch(ArgumentParserException e) {
            assertEquals("too few arguments", e.getMessage());
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    }
   
    @Test
    public void testSubparsersDest() throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers().dest("command");
        subparsers.addParser("install").addArgument("--command")
                .setDefault("default");
        Namespace res = ap.parseArgs("install".split(" "));
        assertEquals("install", res.get("command"));
    }
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    }

    @Test
    public void testSubparserWithoutAddHelp() throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers();
        subparsers.addParser("install", false, ArgumentParsers.DEFAULT_PREFIX_CHARS);
        try {
            ap.parseArgs("install -h".split(" "));
            fail();
        } catch (ArgumentParserException e) {
            assertEquals("unrecognized arguments: '-h'", e.getMessage());
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

        mutex2.addArgument("-g");
        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,
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    @Test
    public void testSubparserFormatHelp() throws ArgumentParserException {
        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,
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    @Test
    public void testSubparserFormatHelpWithDefaultHelp()
            throws ArgumentParserException {
        ap.addArgument("--bar");
        Subparsers subparsers = ap.addSubparsers();
        Subparser parser = subparsers.addParser("install").defaultHelp(true);
        parser.addArgument("--foo").setDefault("alpha");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j install [-h] [--foo FOO]%n"
                + "%n"
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    @Test
    public void testFormatHelpWithSubparserTitleDescription()
            throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers().help("subcommand help")
                .title("mysubcommands").description("valid subcommands");
        subparsers.addParser("install").help("install help");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j [-h] {install} ...%n"
                + "%n"
                + "optional arguments:%n"
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    @Test
    public void testFormatHelpWithSubparserAlias()
            throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers().help("subcommand help")
                .title("mysubcommands").description("valid subcommands");
        subparsers.addParser("clone").help("clone help");
        subparsers.addParser("checkout").aliases("co").help("checkout help");
        subparsers.addParser("remove").aliases("rm","del").help("remove help");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j [-h] {clone,checkout,co,remove,rm,del} ...%n"
View Full Code Here

Examples of net.sourceforge.argparse4j.inf.Subparsers.addParser()

    public void testFormatHelpWithSubparserAlias()
            throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers().help("subcommand help")
                .title("mysubcommands").description("valid subcommands");
        subparsers.addParser("clone").help("clone help");
        subparsers.addParser("checkout").aliases("co").help("checkout help");
        subparsers.addParser("remove").aliases("rm","del").help("remove help");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j [-h] {clone,checkout,co,remove,rm,del} ...%n"
                + "%n"
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.