private String [ ] augmentCommand ( String [ ] args , Class < ? extends Command > cmd , boolean acceptsInputFile ) { OptionGroup < ID > options ; try { if ( acceptsInputFile ) { options = OptionIntrospector . introspect ( cmd , InputFileCommand . class ) ; } else { options = OptionIntrospector . introspect ( cmd ) ; } } catch ( IntrospectionException e ) { //should never happen throw new RuntimeException ( e ) ; } ShellContext sc = ShellContext . current ( ) ; for ( Option < ID > o : options . getOptions ( ) ) { if ( o . getLongName ( ) . equals ( "style" ) ) { args = ArrayUtils . add ( args , "--style" ) ; args = ArrayUtils . add ( args , sc . getStyle ( ) ) ; } else if ( o . getLongName ( ) . equals ( "locale" ) ) { args = ArrayUtils . add ( args , "--locale" ) ; args = ArrayUtils . add ( args , sc . getLocale ( ) ) ; } else if ( o . getLongName ( ) . equals ( "format" ) ) { args = ArrayUtils . add ( args , "--format" ) ; args = ArrayUtils . add ( args , sc . getFormat ( ) ) ; } else if ( o . getLongName ( ) . equals ( "input" ) && sc . getInputFile ( ) != null && ! sc . getInputFile ( ) . isEmpty ( ) ) { args = ArrayUtils . add ( args , "--input" ) ; args = ArrayUtils . add ( args , sc . getInputFile ( ) ) ; } } return args ; }
Augments the given command line with context variables