protected Command . Template parse ( Command . Descriptor root , String [ ] args , int index ) { ArrayList < Command . Option > options = new ArrayList <> ( ) ; ArrayList < String > arguments = new ArrayList <> ( ) ; // Command . Template sub = null ; while ( index < args . length ) { String arg = args [ index ] ; if ( isLongOption ( arg ) ) { options . add ( parseLongOption ( root , args [ index ] ) ) ; } else if ( isCommand ( arg , root . getCommands ( ) ) ) { Command . Descriptor cmd = getCommandDescriptor ( arg , root . getCommands ( ) ) ; sub = parse ( cmd , args , index + 1 ) ; break ; } else { arguments . add ( arg ) ; } index = index + 1 ; } // Command . Options optionMap = new OptionsMap ( options , root . getOptionDescriptors ( ) ) ; // return new ConcreteTemplate ( root , optionMap , arguments , sub ) ; }
Parse a given set of command - line arguments starting from a given index position to produce an appropriate command template .