public static int validate ( String ... argv ) throws InterruptedException { if ( argv . length < 1 ) { printHelp ( "Target not specified." ) ; return - 2 ; } String command = argv [ 0 ] ; String name = null ; String [ ] args ; int argsLength = 0 ; // Find all non-option command line arguments. while ( argsLength < argv . length && ! argv [ argsLength ] . startsWith ( "-" ) ) { argsLength ++ ; } if ( argsLength > 1 ) { name = argv [ 1 ] ; args = Arrays . copyOfRange ( argv , 2 , argv . length ) ; } else { args = Arrays . copyOfRange ( argv , 1 , argv . length ) ; } CommandLine cmd ; try { cmd = parseArgsAndOptions ( OPTIONS , args ) ; } catch ( InvalidArgumentException e ) { System . err . format ( "Invalid argument: %s.%n" , e . getMessage ( ) ) ; return - 1 ; } if ( command != null && command . equals ( "list" ) ) { printTasks ( ) ; return 0 ; } return runTasks ( command , name , cmd ) ; }
Validates environment .