static ConsoleCallback passwordCallback;
public static void main(String[] args) throws IOException {
//Settings.getInstance().setAnsiConsole(false);
SettingsBuilder builder = new SettingsBuilder();
builder.readInputrc(false).logging(true);
builder.logfile(System.getProperty("user.dir") + System.getProperty("file.separator") + "aesh_example.log");
//Settings.getInstance().setAliasEnabled(true);
//Settings.getInstance().setAliasFile(new File(System.getProperty("user.dir")+Config.getPathSeparator()+"aesh_aliases.txt"));
//Settings.getInstance().setPersistAlias(true);
//Settings.getInstance().enableOperatorParser(false);
//Settings.getInstance().setHistoryDisabled(true);
//Settings.getInstance().setHistoryPersistent(false);
List<TerminalCharacter> chars = new ArrayList<TerminalCharacter>();
chars.add(new TerminalCharacter('[', new TerminalColor(Color.BLUE, Color.DEFAULT)));
chars.add(new TerminalCharacter('t', new TerminalColor(Color.RED, Color.DEFAULT),
CharacterType.ITALIC));
chars.add(new TerminalCharacter('e', new TerminalColor(Color.RED, Color.DEFAULT),
CharacterType.INVERT));
chars.add(new TerminalCharacter('s', new TerminalColor(Color.RED, Color.DEFAULT),
CharacterType.CROSSED_OUT));
chars.add(new TerminalCharacter('t', new TerminalColor(Color.RED ,Color.DEFAULT),
CharacterType.BOLD));
chars.add(new TerminalCharacter(']', new TerminalColor(Color.BLUE, Color.DEFAULT),
CharacterType.FAINT));
chars.add(new TerminalCharacter('$', new TerminalColor(Color.GREEN, Color.DEFAULT),
CharacterType.UNDERLINE));
chars.add(new TerminalCharacter(' ', new TerminalColor(Color.DEFAULT, Color.DEFAULT)));
final Prompt prompt = new Prompt(chars);
//String prompt = ANSI.redText()+"[test@foo]"+ANSI.reset()+"$ ";
//a simple interruptHook
builder.interruptHook(new InterruptHook() {
@Override
public void handleInterrupt(Console console, Action action) {
if(action == Action.INTERRUPT) {
console.getShell().out().println("^C");
console.clearBufferAndDisplayPrompt();
}
else if(action == Action.IGNOREEOF) {
console.getShell().out().println("Use \"exit\" to leave the shell.");
console.clearBufferAndDisplayPrompt();
}
else {
console.getShell().out().println();
console.stop();
}
}
});
final Console exampleConsole = new Console(builder.create());
Completion completer = new Completion() {
@Override
public void complete(CompleteOperation co) {
// very simple completor