Package org.jnode.shell.syntax

Examples of org.jnode.shell.syntax.Syntax


    }

    @org.junit.Test
    public void testFormat() {
        Test test = new Test();
        Syntax syntax1 = new OptionSyntax("fileArg", "file", 'f');
        Assert.assertEquals("--file | -f <fileArg>", syntax1.format(test.getArgumentBundle()));
        Syntax syntax2 = new OptionSyntax("intArg", "int");
        Assert.assertEquals("--int <intArg>", syntax2.format(test.getArgumentBundle()));
        Syntax syntax3 = new OptionSyntax("intArg", 'i');
        Assert.assertEquals("-i <intArg>", syntax3.format(test.getArgumentBundle()));
        Syntax syntax4 = new OptionSyntax("flagArg", "xxx", 'x');
        Assert.assertEquals("--xxx | -x", syntax4.format(test.getArgumentBundle()));
    }
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

            if (bundle == null) {
                // We're missing the argument bundle.  We assume this is a 'classic' Java application
                // that does its own argument parsing and completion like a UNIX shell; i.e.
                // completing each argument as a pathname.
                Syntax syntax = new RepeatSyntax(new ArgumentSyntax("argument"));
                syntaxes = new SyntaxBundle(cmd, syntax);
                bundle = new ArgumentBundle(
                    new FileArgument("argument", Argument.MULTIPLE));
            } else if (syntaxes == null) {
                // We're missing the syntax, but we do have an argument bundle.  Generate
View Full Code Here

    }

    @org.junit.Test
    public void testFormat() {
        Test test = new Test();
        Syntax syntax1 =
                new AlternativesSyntax(new OptionSyntax("intArg", 'i'), new OptionSyntax("fileArg",
                        'f'), new OptionSyntax("flagArg", "xxx"));
        Assert.assertEquals("( -i <intArg> ) | ( -f <fileArg> ) | --xxx",
                syntax1.format(test.getArgumentBundle()));
    }
View Full Code Here

    }

    @org.junit.Test
    public void testFormat() {
        Test test = new Test();
        Syntax syntax1 = new SequenceSyntax(new ArgumentSyntax("fileArg"));
        Assert.assertEquals("<fileArg>", syntax1.format(test.getArgumentBundle()));
        Syntax syntax2 =
                new SequenceSyntax(new RepeatSyntax(new ArgumentSyntax("fileArg")),
                        new ArgumentSyntax("intArg"));
        Assert.assertEquals("[ <fileArg> ... ] <intArg>", syntax2.format(test.getArgumentBundle()));
        Syntax syntax3 = new SequenceSyntax();
        Assert.assertEquals("", syntax3.format(test.getArgumentBundle()));
    }
View Full Code Here

    }

    @org.junit.Test
    public void testFormat() {
        ArgumentBundle bundle = new Test().getArgumentBundle();
        Syntax syntax1 =
                new PowersetSyntax(new OptionSyntax("intArg", 'i'),
                        new OptionSyntax("fileArg", 'f'));
        Assert.assertEquals("[ ( -i <intArg> ) | ( -f <fileArg> ) ] ...", syntax1.format(bundle));
    }
View Full Code Here

TOP

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

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.