Package org.jnode.shell.alias

Examples of org.jnode.shell.alias.AliasManager


    }

    public void doComplete(CompletionInfo completions, String partial, int flags) {
        try {
            // get the alias manager
            final AliasManager aliasMgr =
                ShellUtils.getShellManager().getCurrentShell().getAliasManager();

            // collect matching aliases
            for (String alias : aliasMgr.aliases()) {
                if (alias.startsWith(partial)) {
                    completions.addCompletion(alias);
                }
            }
        } catch (NameNotFoundException ex) {
View Full Code Here


     * Start this plugin
     */
    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);
View Full Code Here

     * @return the intuited alias name
     * @throws NameNotFoundException
     */
    private String getProbableAlias(String canonicalName) throws NameNotFoundException {
        // This will be problematic in a classic JVM ...
        AliasManager mgr = ShellUtils.getAliasManager();
        for (String alias : mgr.aliases()) {
            try {
                if (mgr.getAliasClassName(alias).equals(canonicalName)) {
                    return alias;
                }
            } catch (NoSuchAliasException e) {
                // This can only occur if an alias is removed while we are working.
                // There's not much we can do about it ... so ignore this.
View Full Code Here

public class Emu {
    protected static void initEnv() throws NamingException {
        if (true) {
            InitialNaming.setNameSpace(new BasicNameSpace());
            InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE);
            final AliasManager aliasMgr = new DefaultAliasManager(new DummyExtensionPoint());
            final ShellManager shellMgr = new DefaultShellManager();
            InitialNaming.bind(AliasManager.NAME, aliasMgr);
            InitialNaming.bind(ShellManager.NAME, shellMgr);
        }
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
        new AliasCommand().execute(args);
    }

    public void execute() throws Exception {
        final AliasManager aliasMgr = ShellUtils.getCurrentAliasManager();

        if (argRemove.isSet()) {
            // remove an alias
            aliasMgr.remove(argRemove.getValue());
        } else if (argAlias.isSet()) {
            // add an alias
            String className = argClass.getValue();
            try {
                // If the className argument is actually an existing alias, use
                // the existing alias's class name as the new alias's class name.
                String tmp = aliasMgr.getAliasClassName(className);
                if (tmp != null) {
                    className = tmp;
                }
            } catch (NoSuchAliasException e) {
                // ignore
            }
            aliasMgr.add(argAlias.getValue(), className);
        } else {
            // list the aliases
            showAliases(aliasMgr, getOutput().getPrintWriter());
        }
    }
View Full Code Here

        if (initialized) {
            return;
        }
        InitialNaming.setNameSpace(new BasicNameSpace());
        InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE);
        AliasManager alias_mgr =
            new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager();
        InitialNaming.bind(AliasManager.NAME, alias_mgr);
        InitialNaming.bind(ShellManager.NAME, new DefaultShellManager());
        InitialNaming.bind(HelpFactory.NAME, new DefaultHelpFactory());
View Full Code Here

            ShellUtils.registerCommandInvoker(ThreadCommandInvoker.FACTORY);
            ShellUtils.registerCommandInvoker(ProcletCommandInvoker.FACTORY);
            ShellUtils.registerCommandInterpreter(DefaultInterpreter.FACTORY);
            ShellUtils.registerCommandInterpreter(RedirectingInterpreter.FACTORY);

            AliasManager am = this.getAliasManager();
            am.add("gc", "org.jnode.command.system.GcCommand");
            am.add("cpuid", "org.jnode.command.system.CpuIDCommand");
            am.add("set", "org.jnode.command.system.SetCommand");
            am.add("dir", "org.jnode.test.shell.MyDirCommand");
            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"))));
View Full Code Here

            ShellUtils.registerCommandInvoker(ThreadCommandInvoker.FACTORY);
            ShellUtils.registerCommandInvoker(ProcletCommandInvoker.FACTORY);
            ShellUtils.registerCommandInterpreter(DefaultInterpreter.FACTORY);
            ShellUtils.registerCommandInterpreter(RedirectingInterpreter.FACTORY);

            AliasManager am = this.getAliasManager();
            am.add("gc", "org.jnode.command.system..GcCommand");
            am.add("cpuid", "org.jnode.command.system.CpuIDCommand");
            am.add("set", "org.jnode.command.system.SetCommand");
            am.add("duh", "org.jnode.test.shell.MyDuhCommand");
            am.add("alias", "org.jnode.test.shell.MyAliasCommand");
            am.add("compile", "org.jnode.test.shell.MyCompileCommand");
            aliasCompletions = new String[]{"alias ", "compile ", "cpuid ", "duh ", "gc ", "set "};
        }
View Full Code Here

TOP

Related Classes of org.jnode.shell.alias.AliasManager

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.