public String [ ] preprocessTaggedOptions ( final String [ ] argArray ) { List < String > finalArgs = new ArrayList <> ( argArray . length ) ; Iterator < String > argIt = Arrays . asList ( argArray ) . iterator ( ) ; while ( argIt . hasNext ( ) ) { final String arg = argIt . next ( ) ; if ( isShortOptionToken ( arg ) ) { replaceTaggedOption ( SHORT_OPTION_PREFIX , arg . substring ( SHORT_OPTION_PREFIX . length ( ) ) , argIt , finalArgs ) ; } else if ( isLongOptionToken ( arg ) ) { replaceTaggedOption ( LONG_OPTION_PREFIX , arg . substring ( LONG_OPTION_PREFIX . length ( ) ) , argIt , finalArgs ) ; } else { // Positional arg, etc., just add it finalArgs . add ( arg ) ; } } return finalArgs . toArray ( new String [ finalArgs . size ( ) ] ) ; }
Given an array of raw arguments provided by the user return an array of args where tagged arguments have been replaced with curated arguments containing a key to be used by the parser to retrieve the actual values .