public static void main ( String [ ] args ) throws Exception { Options options = new Options ( ) ; HelpFormatter hf = new HelpFormatter ( ) ; hf . setWidth ( 100 ) ; options . addOption ( Option . builder ( "i" ) . argName ( "in_path" ) . longOpt ( "input-file" ) . hasArg ( ) . required ( ) . desc ( "path to target jar/aar file" ) . build ( ) ) ; options . addOption ( Option . builder ( "p" ) . argName ( "pkg_name" ) . longOpt ( "package" ) . hasArg ( ) . desc ( "qualified package name" ) . build ( ) ) ; options . addOption ( Option . builder ( "o" ) . argName ( "out_path" ) . longOpt ( "output-file" ) . hasArg ( ) . required ( ) . desc ( "path to processed jar/aar file" ) . build ( ) ) ; options . addOption ( Option . builder ( "h" ) . argName ( "help" ) . longOpt ( "help" ) . desc ( "print usage information" ) . build ( ) ) ; options . addOption ( Option . builder ( "d" ) . argName ( "debug" ) . longOpt ( "debug" ) . desc ( "print debug information" ) . build ( ) ) ; options . addOption ( Option . builder ( "v" ) . argName ( "verbose" ) . longOpt ( "verbose" ) . desc ( "set verbosity" ) . build ( ) ) ; try { CommandLine line = new DefaultParser ( ) . parse ( options , args ) ; if ( line . hasOption ( ' ' ) ) { hf . printHelp ( appName , options , true ) ; return ; } String jarPath = line . getOptionValue ( ' ' ) ; String pkgName = line . getOptionValue ( ' ' , "" ) ; String outPath = line . getOptionValue ( ' ' ) ; boolean debug = line . hasOption ( ' ' ) ; boolean verbose = line . hasOption ( ' ' ) ; if ( ! pkgName . isEmpty ( ) ) { pkgName = "L" + pkgName . replaceAll ( "\\." , "/" ) ; } DefinitelyDerefedParamsDriver . run ( jarPath , pkgName , outPath , debug , verbose ) ; if ( ! new File ( outPath ) . exists ( ) ) { System . out . println ( "Could not write jar file: " + outPath ) ; } } catch ( ParseException pe ) { hf . printHelp ( appName , options , true ) ; } }
This is the main method of the cli tool . It parses the arguments invokes the analysis driver and checks that the output file is written .