Package org.jnode.shell

Examples of org.jnode.shell.CommandLine.parseCommandLine()


        }

        cl =
                new CommandLine(new Token("cmd"), new Token[] {new Token("F1"), new Token("F2")},
                        null);
        cl.parseCommandLine(shell);
    }
}
View Full Code Here


        CommandInfo cmdInfo;
        Command cmd;

        try {
            cl = new CommandLine(new Token("cmd"), new Token[] {}, null);
            cmdInfo = cl.parseCommandLine(shell);
            Assert.fail("no exception");
        } catch (CommandSyntaxException ex) {
            // expected
        }
View Full Code Here

        }

        cl =
                new CommandLine(new Token("cmd"), new Token[] {new Token("-f"), new Token("F1")},
                        null);
        cmdInfo = cl.parseCommandLine(shell);
        cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(1, cmd.getArgumentBundle().getArgument("fileArg").getValues().length);
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("fileArg").getValue()
                .toString());
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
View Full Code Here

        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("flagArg").getValues().length);

        cl =
                new CommandLine(new Token("cmd"), new Token[] {new Token("-i"), new Token("41")},
                        null);
        cmdInfo = cl.parseCommandLine(shell);
        cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("fileArg").getValues().length);
        Assert.assertEquals(1, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
        Assert.assertEquals("41", cmd.getArgumentBundle().getArgument("intArg").getValue()
                .toString());
View Full Code Here

        Assert.assertEquals("41", cmd.getArgumentBundle().getArgument("intArg").getValue()
                .toString());
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("flagArg").getValues().length);

        cl = new CommandLine(new Token("cmd"), new Token[] {new Token("--xxx")}, null);
        cmdInfo = cl.parseCommandLine(shell);
        cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("fileArg").getValues().length);
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
        Assert.assertEquals(1, cmd.getArgumentBundle().getArgument("flagArg").getValues().length);
View Full Code Here

        try {
            cl =
                    new CommandLine(new Token("cmd"), new Token[] {new Token("--xxx"),
                        new Token("-f"), new Token("F1")}, null);
            cl.parseCommandLine(shell);
            Assert.fail("no exception");
        } catch (CommandSyntaxException ex) {
            // expected
        }
    }
View Full Code Here

        TestShell shell = new TestShell();
        shell.addAlias("command", "org.jnode.test.shell.syntax.ArgumentTypesTest$TestEnumCommand");
        shell.addSyntax("command", new ArgumentSyntax("arg1"));
        CommandLine cl =
                new CommandLine(new Token("command"), new Token[] {new Token("ALT1")}, null);
        CommandInfo cmdInfo = cl.parseCommandLine(shell);
        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(TestEnum.ALT1, cmd.getArgumentBundle().getArgument("arg1").getValue());

        try {
            cl = new CommandLine(new Token("command"), new Token[] {new Token("ALT99")}, null);
View Full Code Here

        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(TestEnum.ALT1, cmd.getArgumentBundle().getArgument("arg1").getValue());

        try {
            cl = new CommandLine(new Token("command"), new Token[] {new Token("ALT99")}, null);
            cl.parseCommandLine(shell);
            Assert.fail("parse didn't fail");
        } catch (CommandSyntaxException ex) {
            // expected
        }
        try {
View Full Code Here

        }
        try {
            cl =
                    new CommandLine(new Token("command"), new Token[] {new Token("ALT1"),
                        new Token("ALT1")}, null);
            cl.parseCommandLine(shell);
            Assert.fail("parse didn't fail");
        } catch (CommandSyntaxException ex) {
            // expected
        }
    }
View Full Code Here

    public void testFileArgument() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("command", "org.jnode.test.shell.syntax.ArgumentTypesTest$TestFileCommand");
        shell.addSyntax("command", new ArgumentSyntax("arg1"));
        CommandLine cl = new CommandLine(new Token("command"), new Token[] {new Token("F1")}, null);
        CommandInfo cmdInfo = cl.parseCommandLine(shell);
        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("arg1").getValue().toString());

        try {
            cl = new CommandLine(new Token("command"), new Token[] {new Token("")}, null);
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.