static Shell createTerminalConsoleShell ( String prompt , String appName , ShellCommandHandler mainHandler , InputStream input , OutputStream output ) { try { PrintStream out = new PrintStream ( output ) ; // Build jline terminal jline . Terminal term = TerminalFactory . get ( ) ; final ConsoleReader console = new ConsoleReader ( input , output , term ) ; console . setBellEnabled ( true ) ; console . setHistoryEnabled ( true ) ; // Build console BufferedReader in = new BufferedReader ( new InputStreamReader ( new ConsoleReaderInputStream ( console ) ) ) ; ConsoleIO . PromptListener promptListener = new ConsoleIO . PromptListener ( ) { @ Override public boolean onPrompt ( String prompt ) { console . setPrompt ( prompt ) ; return true ; // suppress normal prompt } } ; return createConsoleShell ( prompt , appName , mainHandler , in , out , out , promptListener ) ; } catch ( Exception e ) { // Failover: use default shell BufferedReader in = new BufferedReader ( new InputStreamReader ( input ) ) ; PrintStream out = new PrintStream ( output ) ; return createConsoleShell ( prompt , appName , mainHandler , in , out , out , null ) ; } }
Facade method for operating the Unix - like terminal supporting line editing and command history .