Package org.jnode.shell.syntax

Examples of org.jnode.shell.syntax.SyntaxManager


    protected void startPlugin() throws PluginException {
        try {
            final ShellManager shellMgr = new DefaultShellManager();
            final AliasManager aliasMgr =
                new DefaultAliasManager(getDescriptor().getExtensionPoint("aliases"));
            final SyntaxManager syntaxMgr =
                new DefaultSyntaxManager(getDescriptor().getExtensionPoint("syntaxes"));
            InitialNaming.bind(AliasManager.NAME, aliasMgr);
            InitialNaming.bind(ShellManager.NAME, shellMgr);
            InitialNaming.bind(SyntaxManager.NAME, syntaxMgr);
        } catch (NamingException ex) {
View Full Code Here


    public Help getHelp(String alias, CommandInfo cmdInfo) throws HelpException {
        SyntaxBundle syntaxes = null;
        ArgumentBundle bundle = null;
        try {
            final Shell shell = ShellUtils.getShellManager().getCurrentShell();
            final SyntaxManager syntaxManager = shell.getSyntaxManager();
            Command cmd = cmdInfo.createCommandInstance();
            if (cmd != null) {
                bundle = cmd.getArgumentBundle();
                syntaxes = syntaxManager.getSyntaxBundle(alias);
                if (syntaxes == null) {
                    syntaxes = new SyntaxBundle(alias, bundle.createDefaultSyntax());
                }
            }
        } catch (Exception ex) {
View Full Code Here

    }
   
    public void execute()  throws Exception {
        PrintWriter out = getOutput().getPrintWriter();
        PrintWriter err = getError().getPrintWriter();
        SyntaxManager synMgr = ShellUtils.getCurrentSyntaxManager();
        if (argDumpAll.isSet()) {
            for (String alias : synMgr.getKeys()) {
                SyntaxBundle bundle = synMgr.getSyntaxBundle(alias);
                dumpSyntax(alias, bundle, out);
            }
        } else {
            String alias;
            if (argDump.isSet()) {
                alias = getAlias();
                SyntaxBundle bundle = synMgr.getSyntaxBundle(alias);
                if (bundle == null) {
                    err.format(err_no_alias, alias);
                } else {
                    dumpSyntax(alias, bundle, out);
                }
            } else if (argFile.isSet()) {
                alias = getAlias();
                File file = argFile.getValue();
                XMLElement xml = new XMLElement();
                FileReader reader = null;
                try {
                    reader = new FileReader(file);
                    xml.parseFromReader(new BufferedReader(reader));
                    xml.setAttribute("alias", alias);
                    SyntaxBundle bundle =
                        new SyntaxSpecLoader().loadSyntax(new XMLSyntaxSpecAdapter(xml));
                    synMgr.add(bundle);
                } catch (IOException ex) {
                    err.format(err_file_read, alias, ex.getLocalizedMessage());
                } finally {
                    if (reader != null) {
                        reader.close();
                    }
                }
            } else if (argRemove.isSet()) {
                alias = getAlias();
                synMgr.remove(alias);
            } else {
                for (String key : synMgr.getKeys()) {
                    out.println(key);
                }
            }
        }
    }
View Full Code Here

            am.add("duh", "org.jnode.test.shell.MyDuhCommand");
            am.add("cat", "org.jnode.test.shell.MyCatCommand");
            am.add("alias", "org.jnode.test.shell.MyAliasCommand");
            aliasCompletions = new String[]{"alias ", "cat ", "cpuid ", "dir ", "duh ", "gc ", "set "};

            SyntaxManager sm = this.getSyntaxManager();
            sm.add(new SyntaxBundle("set",
                new SequenceSyntax(new ArgumentSyntax("key"), new ArgumentSyntax("value"))));
            sm.add(new SyntaxBundle("duh", new ArgumentSyntax("path")));
            sm.add(new SyntaxBundle("cpuid", new SequenceSyntax()));
            sm.add(new SyntaxBundle("alias",
                new EmptySyntax(null, "Print all available aliases and corresponding classnames"),
                new SequenceSyntax(null, "Set an aliases for given classnames",
                    new ArgumentSyntax("alias"), new ArgumentSyntax("classname")),
                new OptionSyntax("remove", 'r', null, "Remove an alias")));
        }
View Full Code Here

TOP

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

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.