📄 aliascommand.java
字号:
/*
* $Id: AliasCommand.java,v 1.1 2003/11/25 11:52:58 epr Exp $
*/
package org.jnode.shell.command;
import java.util.Iterator;
import javax.naming.NameNotFoundException;
import org.jnode.shell.Shell;
import org.jnode.shell.ShellUtils;
import org.jnode.shell.alias.AliasManager;
import org.jnode.shell.alias.NoSuchAliasException;
import org.jnode.shell.help.*;
/**
* @author epr
* @author qades
*/
public class AliasCommand {
static final AliasArgument ARG_ALIAS = new AliasArgument("alias", "the alias");
static final ClassNameArgument ARG_CLASS = new ClassNameArgument("classname", "the classname");
static final Parameter PARAM_REMOVE = new Parameter("r", "following alias will be removed", ARG_ALIAS, Parameter.MANDATORY);
public static Help.Info HELP_INFO = new Help.Info(
"alias", new Syntax[] {
new Syntax("Print all available aliases and corresponding classnames"),
new Syntax("Set an aliases for given classnames",
new Parameter[] {
new Parameter(ARG_ALIAS, Parameter.MANDATORY),
new Parameter(ARG_CLASS, Parameter.MANDATORY)
}
), new Syntax("Remove an alias",
new Parameter[] {
PARAM_REMOVE
}
)
});
public static void main(String[] args) throws NoSuchAliasException, NameNotFoundException {
ParsedArguments cmdLine = HELP_INFO.parse(args);
final Shell shell = ShellUtils.getShellManager().getCurrentShell();
final AliasManager aliasMgr = shell.getAliasManager();
if (cmdLine.size() == 0) {
for (Iterator i = aliasMgr.aliasIterator(); i.hasNext();) {
final String alias = (String) i.next();
System.out.println(alias + ":\t" + aliasMgr.getAliasClassName(alias));
}
} else if (PARAM_REMOVE.isSet(cmdLine)) {
// remove an alias
aliasMgr.remove(ARG_ALIAS.getValue(cmdLine));
} else {
// add an alias
aliasMgr.add(ARG_ALIAS.getValue(cmdLine), ARG_CLASS.getValue(cmdLine));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -