private void interpretCommandLine ( CommandLine commandLine , Options options , TaskFactory taskFactory ) throws CliExecutionException { if ( commandLine . hasOption ( OPTION_HELP ) ) { printUsage ( options , null ) ; System . exit ( 1 ) ; } List < String > taskNames = commandLine . getArgList ( ) ; if ( taskNames . isEmpty ( ) ) { printUsage ( options , "A task must be specified, i.e. one of " + gatherTaskNames ( taskFactory ) ) ; System . exit ( 1 ) ; } List < Task > tasks = new ArrayList <> ( ) ; for ( String taskName : taskNames ) { Task task = taskFactory . fromName ( taskName ) ; if ( task == null ) { printUsage ( options , "Unknown task " + taskName ) ; } tasks . add ( task ) ; } Map < String , Object > properties = readProperties ( commandLine ) ; PluginRepository pluginRepository = getPluginRepository ( ) ; try { executeTasks ( tasks , options , commandLine , pluginRepository , properties ) ; } catch ( PluginRepositoryException e ) { throw new CliExecutionException ( "Unexpected plugin repository problem while executing tasks." , e ) ; } }
Parse the command line and execute the requested task .