public String [ ] init ( String [ ] argv , int min , int max , Collection < CommandLineParser . Option > options ) throws IOException , SAXException { // parse command line parser = new CommandLineParser ( ) ; parser . setMinimumArguments ( min ) ; parser . setMaximumArguments ( max ) ; parser . registerOption ( new CommandLineParser . BooleanOption ( "reindex" , ' ' ) ) ; if ( options != null ) for ( CommandLineParser . Option option : options ) parser . registerOption ( option ) ; try { argv = parser . parse ( argv ) ; } catch ( CommandLineParser . CommandLineParserException e ) { System . err . println ( "ERROR: " + e . getMessage ( ) ) ; usage ( ) ; System . exit ( 1 ) ; } // do we need to reindex? boolean reindex = parser . getOptionState ( "reindex" ) ; // load configuration config = ConfigLoader . load ( argv [ 0 ] ) ; database = config . getDatabase ( reindex ) ; // overwrite iff reindex if ( database . isInMemory ( ) ) reindex = true ; // no other way to do it in this case // reindex, if requested if ( reindex ) reindex ( config , database ) ; return argv ; }
These exact lines are shared between three different tools so they have been moved here to reduce code duplication .