public static void main ( final String [ ] args ) { if ( args . length == 0 ) { printHelp ( ) ; System . exit ( 0 ) ; } List < String > zipNames = new ArrayList < String > ( ) ; List < String > jarNames = new ArrayList < String > ( ) ; String destDir = null ; boolean jarActive = false , zipActive = false , destDirActive = false ; boolean verbose = false ; // process arguments for ( int i = 0 ; i < args . length ; i ++ ) { String arg = args [ i ] ; if ( arg . charAt ( 0 ) == ' ' ) { // switch arg = arg . substring ( 1 ) ; if ( arg . equalsIgnoreCase ( "jar" ) ) { jarActive = true ; zipActive = false ; destDirActive = false ; } else if ( arg . equalsIgnoreCase ( "zip" ) ) { zipActive = true ; jarActive = false ; destDirActive = false ; } else if ( arg . equalsIgnoreCase ( "dir" ) ) { jarActive = false ; zipActive = false ; destDirActive = true ; } else if ( arg . equalsIgnoreCase ( "verbose" ) ) { verbose = true ; } else { reportError ( "Invalid switch - " + arg ) ; } } else { if ( jarActive ) { jarNames . add ( arg ) ; } else if ( zipActive ) { zipNames . add ( arg ) ; } else if ( destDirActive ) { if ( destDir != null ) { reportError ( "duplicate argument - " + "-destDir" ) ; } destDir = arg ; } else { reportError ( "Too many parameters - " + arg ) ; } } } if ( destDir == null || ( zipNames . size ( ) + jarNames . size ( ) ) == 0 ) { reportError ( "Missing parameters" ) ; } if ( verbose ) { System . out . println ( "Effective command: " + ZipExploder . class . getName ( ) + " " + ( jarNames . size ( ) > 0 ? "-jars " + jarNames + " " : "" ) + ( zipNames . size ( ) > 0 ? "-zips " + zipNames + " " : "" ) + "-dir " + destDir ) ; } try { ZipExploder ze = new ZipExploder ( verbose ) ; ze . process ( FileUtils . pathNamesToFiles ( zipNames . toArray ( new String [ zipNames . size ( ) ] ) ) , FileUtils . pathNamesToFiles ( jarNames . toArray ( new String [ jarNames . size ( ) ] ) ) , new File ( destDir ) ) ; } catch ( IOException ioe ) { System . err . println ( "Exception - " + ioe . getMessage ( ) ) ; ioe . printStackTrace ( ) ; // *** debug *** System . exit ( 2 ) ; } }
Main command line entry point .