// Path: commons/src/main/java/com/vlkan/hrrs/commons/logger/LoggerLevelAccessor.java
// public interface LoggerLevelAccessor {
// 
//     String getRootLevel();
// 
//     void setRootLevel(String levelName);
// 
//     String getLevel(String loggerName);
// 
//     void setLevel(String loggerName, String levelName);
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/logger/LoggerLevels.java
// public enum LoggerLevels {;
// 
//     public static void applyLoggerLevelSpecs(String loggerLevelSpecs, LoggerLevelAccessor loggerLevelAccessor) {
//         if (loggerLevelSpecs != null) {
//             for (String loggerNameAndLoggerLevel : loggerLevelSpecs.split(",")) {
//                 String[] fields = loggerNameAndLoggerLevel.split("=", 2);
//                 String loggerName = fields[0];
//                 String loggerLevel = fields[1];
//                 if ("*".equals(loggerName)) {
//                     loggerLevelAccessor.setRootLevel(loggerLevel);
//                 } else {
//                     loggerLevelAccessor.setLevel(loggerName, loggerLevel);
//                 }
//             }
//         }
//     }
// 
// }


import com.google.inject.Guice;
import com.google.inject.Injector;
import com.vlkan.hrrs.api.*;
import com.vlkan.hrrs.commons.logger.LoggerLevelAccessor;
import com.vlkan.hrrs.commons.logger.LoggerLevels;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.*;
import java.net.URI;
        };
    }

    @Override
    public void close() {

        // Close the reader source.
        try {
            reader.getSource().close();
        } catch (IOException error) {
            String message = String.format("failed closing reader source (inputUri=%s)", config.getInputUri());
            LOGGER.error(message, error);
        }

        // Close the writer source.
        try {
            writer.getTarget().close();
        } catch (IOException error) {
            String message = String.format("failed closing writer target (outputUri=%s)", config.getOutputUri());
            LOGGER.error(message, error);
        }

    }

    public static void main(String[] args, DistillerModuleFactory moduleFactory) {
        Config config = Config.of(args);
        config.dump();
        DistillerModule module = moduleFactory.create(config);
        Injector injector = Guice.createInjector(module);
        LoggerLevelAccessor loggerLevelAccessor = injector.getInstance(LoggerLevelAccessor.class);
// Path: commons/src/main/java/com/vlkan/hrrs/commons/logger/LoggerLevelAccessor.java
// public interface LoggerLevelAccessor {
// 
//     String getRootLevel();
// 
//     void setRootLevel(String levelName);
// 
//     String getLevel(String loggerName);
// 
//     void setLevel(String loggerName, String levelName);
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/logger/LoggerLevels.java
// public enum LoggerLevels {;
// 
//     public static void applyLoggerLevelSpecs(String loggerLevelSpecs, LoggerLevelAccessor loggerLevelAccessor) {
//         if (loggerLevelSpecs != null) {
//             for (String loggerNameAndLoggerLevel : loggerLevelSpecs.split(",")) {
//                 String[] fields = loggerNameAndLoggerLevel.split("=", 2);
//                 String loggerName = fields[0];
//                 String loggerLevel = fields[1];
//                 if ("*".equals(loggerName)) {
//                     loggerLevelAccessor.setRootLevel(loggerLevel);
//                 } else {
//                     loggerLevelAccessor.setLevel(loggerName, loggerLevel);
//                 }
//             }
//         }
//     }
// 
// }


// Path: distiller/src/main/java/com/vlkan/hrrs/distiller/cli/Distiller.java
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.vlkan.hrrs.api.*;
import com.vlkan.hrrs.commons.logger.LoggerLevelAccessor;
import com.vlkan.hrrs.commons.logger.LoggerLevels;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.*;
import java.net.URI;

        };
    }

    @Override
    public void close() {

        // Close the reader source.
        try {
            reader.getSource().close();
        } catch (IOException error) {
            String message = String.format("failed closing reader source (inputUri=%s)", config.getInputUri());
            LOGGER.error(message, error);
        }

        // Close the writer source.
        try {
            writer.getTarget().close();
        } catch (IOException error) {
            String message = String.format("failed closing writer target (outputUri=%s)", config.getOutputUri());
            LOGGER.error(message, error);
        }

    }

    public static void main(String[] args, DistillerModuleFactory moduleFactory) {
        Config config = Config.of(args);
        config.dump();
        DistillerModule module = moduleFactory.create(config);
        Injector injector = Guice.createInjector(module);
        LoggerLevelAccessor loggerLevelAccessor = injector.getInstance(LoggerLevelAccessor.class);
        LoggerLevels.applyLoggerLevelSpecs(config.getLoggerLevelSpecs(), loggerLevelAccessor);