Examples of FileArgument


Examples of org.jnode.shell.syntax.FileArgument

                // 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
                // a default syntax from the bundle.
                syntaxes = new SyntaxBundle(cmd, bundle.createDefaultSyntax());
            }  
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    }

    @Test
    public void testStatefullParsing2() throws NoTokensAvailableException, CommandSyntaxException {
        IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <start> ::= <<intArg>> <<fileArg>>
        MuSyntax syntax = new MuSequence(new MuArgument("intArg"), new MuArgument("fileArg"));
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"1", "x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);

        Assert.assertEquals(new Integer(1), intArg.getValue());
        Assert.assertEquals(new File("x"), fileArg.getValue());

        try {
            cl = new CommandLine(new String[] {"1"});
            parser.parse(syntax, null, cl.tokenIterator(), bundle);
            Assert.fail("parse didn't fail");
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    }

    @Test
    public void testStatefullParsing3() throws NoTokensAvailableException, CommandSyntaxException {
        IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <start> :: = <<intArg>> | <<fileArg>>
        MuSyntax syntax = new MuAlternation(new MuArgument("intArg"), new MuArgument("fileArg"));
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"1"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(new Integer(1), intArg.getValue());
        Assert.assertEquals(false, fileArg.isSet());

        cl = new CommandLine(new String[] {"x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(new File("x"), fileArg.getValue());
        Assert.assertEquals(false, intArg.isSet());

    }
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    }

    @Test
    public void testStatefullParsing4() throws NoTokensAvailableException, CommandSyntaxException {
        IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <root> ::= <<fileArg>> | ( <<intArg>> <root> )
        MuSyntax syntax =
                new MuAlternation("root", new MuArgument("fileArg"), new MuSequence(new MuArgument(
                        "intArg"), new MuBackReference("root")));
        syntax.resolveBackReferences();

        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(1, fileArg.getValues().length);
        Assert.assertEquals(0, intArg.getValues().length);

        cl = new CommandLine(new String[] {"1", "x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(1, fileArg.getValues().length);
        Assert.assertEquals(1, intArg.getValues().length);

        cl = new CommandLine(new String[] {"1", "2", "x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(1, fileArg.getValues().length);
        Assert.assertEquals(2, intArg.getValues().length);

        try {
            cl = new CommandLine(new String[] {"1", "2", ""});
            parser.parse(syntax, null, cl.tokenIterator(), bundle);
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    }

    @Test
    public void testStatefullParsing5() throws NoTokensAvailableException, CommandSyntaxException {
        IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
        FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
        ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);

        // <root> ::= ( <<intArg>> <root> ) | <<fileArg>>
        MuSyntax syntax =
                new MuAlternation("root", new MuSequence(new MuArgument("intArg"),
                        new MuBackReference("root")), new MuArgument("fileArg"));
        syntax.resolveBackReferences();
        MuParser parser = new MuParser();
        CommandLine cl;

        cl = new CommandLine(new String[] {"x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(1, fileArg.getValues().length);
        Assert.assertEquals(0, intArg.getValues().length);

        cl = new CommandLine(new String[] {"1", "x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(1, fileArg.getValues().length);
        Assert.assertEquals(1, intArg.getValues().length);

        cl = new CommandLine(new String[] {"1", "1", "x"});
        parser.parse(syntax, null, cl.tokenIterator(), bundle);
        Assert.assertEquals(1, fileArg.getValues().length);
        Assert.assertEquals(2, intArg.getValues().length);

        try {
            cl = new CommandLine(new String[] {"1", "1", ""});
            parser.parse(syntax, null, cl.tokenIterator(), bundle);
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    private boolean verbose;
    private boolean onefs;

    public DeleteCommand() {
        super(help_super);
        argPaths     = new FileArgument("paths", Argument.MANDATORY | Argument.MULTIPLE | Argument.EXISTING, help_file);
        flagRecurse  = new FlagArgument("recursive", Argument.OPTIONAL, help_recurse);
        flagForce    = new FlagArgument("force", Argument.OPTIONAL, help_force);
        flagInteract = new FlagArgument("interactive", Argument.OPTIONAL, help_interact);
        flagVerbose  = new FlagArgument("verbose", Argument.OPTIONAL, help_verbose);
        flagOneFS    = new FlagArgument("onefs", 0, help_onefs);
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    private boolean retry;
    private boolean first = true;
   
    public TailCommand() {
        super("Print the tail end of a list of files, or stdin.");
        Files        = new FileArgument("files", Argument.OPTIONAL | Argument.MULTIPLE, help_files);
        Bytes        = new StringArgument("bytes", Argument.EXISTING | Argument.OPTIONAL, help_bytes);
        Lines        = new StringArgument("lines", Argument.EXISTING | Argument.OPTIONAL, help_lines);
        Follow       = new FlagArgument("follow", Argument.OPTIONAL, help_follow);
        FollowR      = new FlagArgument("followr", Argument.OPTIONAL, help_follow_retry);
        MaxUnchanged = new IntegerArgument("unchanged", Argument.OPTIONAL, help_unchanged);
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    private final FileArgument argFile;
    private final URLArgument argURL;

    public HexdumpCommand() {
        super(help_super);
        argFile = new FileArgument("file", Argument.OPTIONAL | Argument.EXISTING, help_file);
        argURL  = new URLArgument("url", Argument.OPTIONAL | Argument.EXISTING, help_url);
        registerArguments(argFile, argURL);
    }
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    private boolean useStreams;
   
    public CatCommand() {
        super(HELP_SUPER);
        int fileFlags = Argument.MULTIPLE | Argument.EXISTING | FileArgument.HYPHEN_IS_SPECIAL;
        argFile    = new FileArgument("file", fileFlags, HELP_FILE);
        argNumNB   = new FlagArgument("num-nonblank", 0, HELP_NUM_NB);
        argNumAll  = new FlagArgument("num", 0, HELP_NUM);
        argEnds    = new FlagArgument("show-ends", 0, HELP_ENDS);
        argSqueeze = new FlagArgument("squeeze", 0, HELP_SQUEEZE);
        registerArguments(argFile, argNumNB, argNumAll, argEnds, argSqueeze);
View Full Code Here

Examples of org.jnode.shell.syntax.FileArgument

    private boolean all;
   
    public DFCommand() {
        super(help_super);
        argDevice  = new DeviceArgument("device", Argument.EXISTING, help_device);
        argPath    = new FileArgument("path", Argument.EXISTING, help_path);
        argReadDec = new FlagArgument("human-read-dec", 0, help_read_dec);
        argReadBin = new FlagArgument("human-read-bin", 0, help_read_bin);
        argAll     = new FlagArgument("show-all", 0, help_all);
        argBlock1k = new FlagArgument("block-size-1k", 0, help_block_1k);
        argBlock   = new IntegerArgument("block-size", 0, help_block);
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.