protected FindCommandResult findAndCreateCommand ( String [ ] args ) throws CommandInitException { String commandName = args [ 0 ] ; String [ ] remainingArguments = StringUtils . stripArgs ( args , 1 ) ; // Check top level commands for app Class < ? extends Command < ? extends CLIContext > > commandClass = _commands . get ( commandName ) ; if ( commandClass == null ) { return null ; } try { // Create the instance of the root class and let that class hunt for any subcommands Command < ? extends CLIContext > rootCmd = ( Command < ? extends CLIContext > ) commandClass . newInstance ( ) ; return rootCmd . findAndCreateCommand ( remainingArguments ) ; } catch ( Exception e ) { throw new CommandInitException ( commandName ) ; } }
Find and create the command instance .