private void execute ( Command command , CommandLineParser lineParser ) { ConsoleWrapper wrappedConsole = new ConsoleWrapper ( console ) ; PrintWriter outputWriter = null ; try { ParsedOptions options = lineParser . parseOptions ( command . getOptions ( ) ) ; outputWriter = OutputRedirection . determineOutputWriter ( lineParser . getRedirectionList ( ) , wrappedConsole ) ; wrappedConsole . setWriter ( outputWriter ) ; command . execute ( options , wrappedConsole ) ; } catch ( ConsoleTerminatedException e ) { throw e ; } catch ( OptionParserException e ) { wrappedConsole . writeError ( e . getMessage ( ) ) ; command . printHelp ( wrappedConsole ) ; } catch ( Exception e ) { log . error ( "Failed to execute command: " + lineParser . getCommandLine ( ) , e ) ; } finally { if ( outputWriter != null ) { outputWriter . close ( ) ; } } }
Executes a command built into Aspectran Shell .