Package org.jnode.shell.CommandLine

Examples of org.jnode.shell.CommandLine.Token


        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;

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

        cl =
                new CommandLine(new Token("cmd"),
                        new Token[] {new Token("--file"), 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());

        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());

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

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

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


        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;

        cl = new CommandLine(new Token("cmd"), new Token[] {}, null);
        cmdInfo = cl.parseCommandLine(shell);
        cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("fileArg").getValues().length);

        cl =
                new CommandLine(new Token("cmd"),
                        new Token[] {new Token("--file"), 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());

        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());

        cl =
                new CommandLine(new Token("cmd"), new Token[] {new Token("-f"), new Token("F1"),
                    new Token("-f"), new Token("F2")}, null);
        cmdInfo = cl.parseCommandLine(shell);
        cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(2, cmd.getArgumentBundle().getArgument("fileArg").getValues().length);

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

        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;

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

        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(0, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("fileArg").getValue()
                .toString());

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

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

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

        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;

        cl = new CommandLine(new Token("cmd"), new Token[] {}, 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(0, cmd.getArgumentBundle().getArgument("otherArg").getValues().length);

        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(0, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("otherArg").getValues().length);
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("fileArg").getValue()
                .toString());

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

        cl =
                new CommandLine(new Token("cmd"), new Token[] {new Token("-i"), new Token("1"),
                    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(1, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("otherArg").getValues().length);
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("fileArg").getValue()
                .toString());
        Assert.assertEquals("1", cmd.getArgumentBundle().getArgument("intArg").getValue()
                .toString());

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

        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;

        cl = new CommandLine(new Token("cmd"), new Token[] {}, 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(0, cmd.getArgumentBundle().getArgument("otherArg").getValues().length);

        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(0, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("otherArg").getValues().length);
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("fileArg").getValue()
                .toString());

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

        cl =
                new CommandLine(new Token("cmd"), new Token[] {new Token("-i"), new Token("1"),
                    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(1, cmd.getArgumentBundle().getArgument("intArg").getValues().length);
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("otherArg").getValues().length);
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("fileArg").getValue()
                .toString());
        Assert.assertEquals("1", cmd.getArgumentBundle().getArgument("intArg").getValue()
                .toString());

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

TOP

Related Classes of org.jnode.shell.CommandLine.Token

Copyright © 2018 www.massapicom. 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.