package com.robusta.pdc;

import com.robusta.pdc.command.line.CommandLineParser;
import com.robusta.pdc.command.line.ParseCommandLineArgumentHasFailed;
import com.robusta.pdc.command.line.UserHasAskedForHelp;
import com.robusta.pdc.domain.CommandLineArguments;
import com.robusta.pdc.domain.ImportTracking;

import static com.robusta.pdc.command.line.CLAParserFactory.parser;
import static com.robusta.pdc.reporting.ReportingFactory.errorReporter;
import static com.robusta.pdc.reporting.ReportingFactory.trackingVisitor;
import static com.robusta.pdc.scanner.ScannerFactory.importStatementScanner;
import static com.robusta.pdc.tracking.ImportTrackingFactory.violationTracking;

/**
 * Entry point into package-dependancy-checker (pdc)
 * using command line. 
 * 
 * <p>Uses a Command line argument (CLA) parser to 
 * process, validate and consume the CLA which is then
 * passed into {@link PackageDependencyChecker}</p>
 * 
 * <p>Handles normal system exit and processing error 
 * exits with appropriate return codes.
 */
public class Main {
    public static void main(String[] args) {
        bootstrap(args);
        try {
            CommandLineArguments cla = parser(errorReporter()).parseCommandLine(args);
            new PackageDependencyChecker().doWork(cla);
        } catch (ParseCommandLineArgumentHasFailed parseCommandLineArgumentHasFailed) {
            System.exit(-1);
        } catch (UserHasAskedForHelp userHasAskedForHelp) {
            System.exit(0);
        }
        System.exit(0);
    }

    private static void bootstrap(String[] args) {
        // Must be done as bootstrap. this will ensure that the logging subsystem is
        // properly setup.

        // If log system is initialized prior to this step, the DomConfigurator needs to
        // be invoked. Adds a nasty dependency to log4j from the app, but there is no
        // slf4j way to reinit the log system.
        new LoggingInterceptor().interceptAndSetup(args);
    }

    public static class PackageDependencyChecker {
        public PackageDependencyChecker() {
        }

        public void doWork(CommandLineArguments cla) throws ParseCommandLineArgumentHasFailed, UserHasAskedForHelp {
            ImportTracking tracking = violationTracking(cla.allowedPackages());
            importStatementScanner(tracking).scan(cla.sourceFolders(), cla.packageNames());
            tracking.allowVisitor(trackingVisitor());
        }
    }

    static class LoggingInterceptor {

        public static final String LOG_LEVEL = "log.level";
        public static final String DEBUG = "DEBUG";
        public static final String INFO = "INFO";

        public void interceptAndSetup(String[] args) {
            boolean isVerbose = false;
            for (String arg : args) {
                if(CommandLineParser.OPTION_HYPHEN_VERBOSE.equals(arg)) {
                    isVerbose = true;
                }
            }
            System.setProperty(LOG_LEVEL, isVerbose ? DEBUG : INFO);
        }
    }
}

@@ -1972,111 +1972,964 @@
     
-public static class PackageDependencyChecker %7B%0A        public PackageDependencyChecker() %7B%0A        %7D%0A%0A 
+/**%0A     * Package Dependecy checker. %0A     * %0A     * %3Cp%3EAccepts a command line arguments with a %0A     * source folders, source packages and target %0A     * packages.%3C/p%3E%0A     * %0A     * %3Cp%3EUses the tracking factory to get a violation %0A     * (import dependancy in source file that is not in%0A     * target packages supplied) kind of import tracker.%0A     * %3C/p%3E%0A     * %0A     * %3Cp%3ESends the import tracker and the command line %0A     * arguments into the scanner factory to get a source%0A     * folders scanner. Calls scan on the scanner%3C/p%3E%0A     * %0A     * %3Cp%3EThe results of the scanning operation is expected%0A     * to be populated into the tracker, so send in a %0A     * reporting visitor into the tracker for visitation of %0A     * tracked contents%3C/p%3E%0A     * %0A     * %3Cp%3EThe tracking visitor implementation used currently%0A     * outputs the dependency tracked information to standard%0A     * output%3C/p%3E%0A     */%0A    public static class PackageDependencyChecker %7B%0A
     

Update Main.java