protected ExitStatus run ( String ... args ) throws Exception { if ( args . length == 0 ) { throw new NoArgumentsException ( ) ; } String commandName = args [ 0 ] ; String [ ] commandArguments = Arrays . copyOfRange ( args , 1 , args . length ) ; Command command = findCommand ( commandName ) ; if ( command == null ) { throw new NoSuchCommandException ( commandName ) ; } beforeRun ( command ) ; try { return command . run ( commandArguments ) ; } finally { afterRun ( command ) ; } }
Parse the arguments and run a suitable command .