@ SafeVarargs public final < T > CommandLine processCommandLine ( final String [ ] args , final Class < ? extends Name < ? > > ... argClasses ) throws IOException , BindException { for ( final Class < ? extends Name < ? > > c : argClasses ) { registerShortNameOfClass ( c ) ; } final Options o = getCommandLineOptions ( ) ; o . addOption ( new Option ( "?" , "help" ) ) ; final Parser g = new GnuParser ( ) ; final org . apache . commons . cli . CommandLine cl ; try { cl = g . parse ( o , args ) ; } catch ( final ParseException e ) { throw new IOException ( "Could not parse config file" , e ) ; } if ( cl . hasOption ( "?" ) ) { new HelpFormatter ( ) . printHelp ( "reef" , o ) ; return null ; } for ( final Option option : cl . getOptions ( ) ) { final String shortName = option . getOpt ( ) ; final String value = option . getValue ( ) ; if ( applicationOptions . containsKey ( option ) ) { applicationOptions . get ( option ) . process ( option ) ; } else { try { conf . bind ( shortNames . get ( shortName ) , value ) ; } catch ( final BindException e ) { throw new BindException ( "Could not bind shortName " + shortName + " to value " + value , e ) ; } } } return this ; }
Process command line arguments .