private void processArgs()

in src/main/java/org/apache/easyant/core/EasyAntMain.java [197:354]


    private void processArgs(CommandLine line) {
        String searchForThis;
        PrintStream logTo = null;

        if (line.hasOption("help")) {
            printUsage();
            return;
        }
        if (easyAntConfiguration.getMsgOutputLevel() >= Project.MSG_VERBOSE || line.hasOption("version")) {
            printVersion();
            if (line.hasOption("version")) {
                return;
            }
        }
        if (line.hasOption("showMemoryDetails")) {
            easyAntConfiguration.setShowMemoryDetails(true);
        }
        if (line.hasOption("diagnostics")) {
            Diagnostics.doReport(System.out, easyAntConfiguration.getMsgOutputLevel());
            return;
        }
        if (line.hasOption("quiet")) {
            easyAntConfiguration.setMsgOutputLevel(Project.MSG_WARN);
        }
        if (line.hasOption("verbose")) {
            easyAntConfiguration.setMsgOutputLevel(Project.MSG_VERBOSE);
        }
        if (line.hasOption("debug")) {
            easyAntConfiguration.setMsgOutputLevel(Project.MSG_DEBUG);
        }
        if (line.hasOption("noinput")) {
            easyAntConfiguration.setAllowInput(false);
        }
        if (line.hasOption("logfile")) {
            try {
                File logFile = new File(line.getOptionValue("logfile"));
                logTo = new PrintStream(new FileOutputStream(logFile));
                isLogFileUsed = true;
            } catch (IOException ioe) {
                String msg = "Cannot write on the specified log file. "
                        + "Make sure the path exists and you have write " + "permissions.";
                throw new BuildException(msg);
            } catch (ArrayIndexOutOfBoundsException aioobe) {
                String msg = "You must specify a log file when " + "using the -log argument";
                throw new BuildException(msg);
            }
        }
        if (line.hasOption("buildmodule")) {
            File buildModule = new File(line.getOptionValue("buildmodule").replace('/', File.separatorChar));
            easyAntConfiguration.setBuildModule(buildModule);
        }
        if (line.hasOption("buildfile")) {
            File buildFile = new File(line.getOptionValue("buildfile").replace('/', File.separatorChar));
            easyAntConfiguration.setBuildFile(buildFile);
        }
        if (line.hasOption("buildconf")) {
            easyAntConfiguration.getActiveBuildConfigurations().add(line.getOptionValue("buildconf"));
        }

        File easyantConfFile = null;

        if (line.hasOption("configfile")) {
            easyantConfFile = new File(line.getOptionValue("configfile").replace('/', File.separatorChar));
        } else {
            // if no command line switch is specified check the default location

            File easyantHome = new File(System.getProperty(EasyAntMagicNames.EASYANT_HOME).replace('/',
                    File.separatorChar));
            File defaultGlobalEasyantConfFile = new File(easyantHome, EasyAntConstants.DEFAULT_GLOBAL_EASYANT_CONF_FILE);

            if (defaultGlobalEasyantConfFile.exists()) {
                easyantConfFile = defaultGlobalEasyantConfFile;
            }
        }

        if (easyantConfFile != null) {
            try {
                easyAntConfiguration = EasyantConfigurationFactory.getInstance().createConfigurationFromFile(
                        easyAntConfiguration, easyantConfFile.toURI().toURL());
            } catch (Exception e) {
                throw new BuildException(e);
            }
        }

        if (line.hasOption("listener")) {
            easyAntConfiguration.getListeners().add(line.getOptionValue("listener"));
        }
        if (line.hasOption("D")) {
            easyAntConfiguration.getDefinedProps().putAll(line.getOptionProperties("D"));
        }
        if (line.hasOption("logger")) {
            if (easyAntConfiguration.getLoggerClassname() != null) {
                throw new BuildException("Only one logger class may be specified.");
            }
            easyAntConfiguration.setLoggerClassname(line.getOptionValue("logger"));
        }
        if (line.hasOption("inputhandler")) {
            if (easyAntConfiguration.getInputHandlerClassname() != null) {
                throw new BuildException("Only one input handler class may " + "be specified.");
            }
            easyAntConfiguration.setInputHandlerClassname(line.getOptionValue("inputhandler"));
        }
        if (line.hasOption("emacs")) {
            easyAntConfiguration.setEmacsMode(true);
        }
        if (line.hasOption("projecthelp")) {
            // set the flag to display the targets and quit
            projectHelp = true;
        }
        if (line.hasOption("find")) {
            // eat up next arg if present, default to module.ivy
            if (line.getOptionValues("find").length > 0) {
                searchForThis = line.getOptionValue("find");

            } else {
                searchForThis = EasyAntConstants.DEFAULT_BUILD_MODULE;
            }
            easyAntConfiguration.setBuildModule(new File(searchForThis));
            easyAntConfiguration.setBuildModuleLookupEnabled(true);
        }
        if (line.hasOption("propertyfile")) {
            propertyFiles.add(line.getOptionValue("propertyfile"));
        }
        if (line.hasOption("keep-going")) {
            easyAntConfiguration.setKeepGoingMode(true);
        }
        if (line.hasOption("offline")) {
            easyAntConfiguration.setOffline(true);
        }
        if (line.hasOption("nice")) {
            easyAntConfiguration.setThreadPriority(Integer.decode(line.getOptionValue("nice")));

            if (easyAntConfiguration.getThreadPriority() < Thread.MIN_PRIORITY
                    || easyAntConfiguration.getThreadPriority() > Thread.MAX_PRIORITY) {
                throw new BuildException("Niceness value is out of the range 1-10");
            }
        }
        if (line.hasOption("autoproxy")) {
            easyAntConfiguration.setProxy(true);
        }
        if (!line.getArgList().isEmpty()) {
            for (Object o : line.getArgList()) {
                String target = (String) o;
                easyAntConfiguration.getTargets().add(target);
            }
        }

        // Load the property files specified by -propertyfile
        loadPropertyFiles();

        if (logTo != null) {
            easyAntConfiguration.setOut(logTo);
            easyAntConfiguration.setErr(logTo);
            System.setOut(easyAntConfiguration.getOut());
            System.setErr(easyAntConfiguration.getErr());
        }
        readyToRun = true;
    }