Package org.jnode.shell.syntax

Examples of org.jnode.shell.syntax.RepeatSyntax


    @org.junit.Test
    public void testTwo() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.OptionSyntaxTest$Test");
        shell.addSyntax("cmd", new RepeatSyntax(new OptionSyntax("fileArg", "file", 'f')));

        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;
View Full Code Here


    }

    @org.junit.Test
    public void testFormat() {
        Test test = new Test();
        Syntax syntax1 = new RepeatSyntax(new ArgumentSyntax("arg1"));
        Assert.assertEquals("[ <arg1> ... ]", syntax1.format(test.getArgumentBundle()));
        Syntax syntax2 = new RepeatSyntax(new ArgumentSyntax("arg1"), 1, Integer.MAX_VALUE);
        Assert.assertEquals("<arg1> ...", syntax2.format(test.getArgumentBundle()));
        Syntax syntax3 = new RepeatSyntax(new ArgumentSyntax("arg1"), 1, 2);
        Assert.assertEquals("<arg1> ...2", syntax3.format(test.getArgumentBundle()));
        Syntax syntax4 = new RepeatSyntax(new ArgumentSyntax("arg1"), 3, 6);
        Assert.assertEquals("<arg1> 3...6", syntax4.format(test.getArgumentBundle()));
    }
View Full Code Here

    @org.junit.Test
    public void testZeroToMany() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.RepeatSyntaxTest$Test");
        shell.addSyntax("cmd", new RepeatSyntax(new ArgumentSyntax("arg1")));

        CommandLine cl = new CommandLine(new Token("cmd"), new Token[] {}, null);
        CommandInfo cmdInfo = cl.parseCommandLine(shell);
        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("arg1").getValues().length);
View Full Code Here

    @org.junit.Test
    public void testOneToMany() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.RepeatSyntaxTest$Test");
        shell.addSyntax("cmd", new RepeatSyntax(new ArgumentSyntax("arg1"), 1, Integer.MAX_VALUE));

        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;
View Full Code Here

    @org.junit.Test
    public void testOneToTwo() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.RepeatSyntaxTest$Test");
        shell.addSyntax("cmd", new RepeatSyntax(new ArgumentSyntax("arg1"), 1, 2));

        CommandLine cl;
        CommandInfo cmdInfo;
        Command cmd;
View Full Code Here

    @org.junit.Test
    public void testThreeToSix() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.RepeatSyntaxTest$Test");
        shell.addSyntax("cmd", new RepeatSyntax(new ArgumentSyntax("arg1"), 3, 6));

        CommandLine cl;
        CommandInfo cmdInfo;
        @SuppressWarnings("unused")
        Command cmd;
View Full Code Here

    @org.junit.Test
    public void testLazy() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.RepeatSyntaxTest$Test");
        shell.addSyntax("cmd", new SequenceSyntax(new RepeatSyntax(new ArgumentSyntax("arg1")),
                new RepeatSyntax(new ArgumentSyntax("arg2"))));

        CommandLine cl = new CommandLine(new Token("cmd"), new Token[] {}, null);
        CommandInfo cmdInfo = cl.parseCommandLine(shell);
        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("arg1").getValues().length);
View Full Code Here

    @org.junit.Test
    public void testEager() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.RepeatSyntaxTest$Test");
        shell.addSyntax("cmd", new SequenceSyntax(new RepeatSyntax(null, new ArgumentSyntax("arg1"), 0,
            Integer.MAX_VALUE, true, null), new RepeatSyntax(new ArgumentSyntax("arg2"))));

        CommandLine cl = new CommandLine(new Token("cmd"), new Token[] {}, null);
        CommandInfo cmdInfo = cl.parseCommandLine(shell);
        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals(0, cmd.getArgumentBundle().getArgument("arg1").getValues().length);
View Full Code Here

    @Test
    public void testOptionalMultiArgument() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.ArgumentMultiplicityTest$OptionalMulti");
        shell.addSyntax("cmd", new RepeatSyntax(new ArgumentSyntax("arg1")));
        CommandLine cl = new CommandLine(new Token("cmd"), new Token[] {new Token("F1")}, null);
        CommandInfo cmdInfo = cl.parseCommandLine(shell);
        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("arg1").getValue().toString());
View Full Code Here

    @Test
    public void testMandatoryMultiArgument() throws Exception {
        TestShell shell = new TestShell();
        shell.addAlias("cmd", "org.jnode.test.shell.syntax.ArgumentMultiplicityTest$MandatoryMulti");
        shell.addSyntax("cmd", new RepeatSyntax(new ArgumentSyntax("arg1")));
        CommandLine cl = new CommandLine(new Token("cmd"), new Token[] {new Token("F1")}, null);
        CommandInfo cmdInfo = cl.parseCommandLine(shell);
        Command cmd = cmdInfo.createCommandInstance();
        Assert.assertEquals("F1", cmd.getArgumentBundle().getArgument("arg1").getValue().toString());
View Full Code Here

TOP

Related Classes of org.jnode.shell.syntax.RepeatSyntax

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.