// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/JCommanderConfig.java
// public interface JCommanderConfig {
// 
//     boolean isHelp();
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/JCommanderConfigs.java
// public enum JCommanderConfigs {;
// 
//     public static <C extends JCommanderConfig> C create(String[] args, C config) {
//         JCommander jCommander = null;
//         try {
//             jCommander = new JCommander(config);
//             jCommander.parse(args);
//         } catch (ParameterException error) {
//             System.err.println(error.getMessage());
//             System.err.println("Run with --help, -h for the list of available parameters.");
//             System.exit(1);
//         }
//         if (config.isHelp()) {
//             jCommander.usage();
//             System.exit(0);
//         }
//         return config;
//     }
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/validator/LoggerLevelSpecsValidator.java
// public class LoggerLevelSpecsValidator implements IParameterValidator {
// 
//     private static final String LOGGER_LEVEL_SPECS_REGEX = createLoggerLevelSpecsRegex();
// 
//     private static String createLoggerLevelSpecsRegex() {
//         String packageNameRegex = "[\\p{L}_$][\\p{L}\\p{N}_$]*";
//         String loggerNameRegex = String.format("%s(\\.%s)*", packageNameRegex, packageNameRegex);
//         String loggerLevelRegex = "(trace|debug|info|warn|error)";
//         String loggerLevelSpecRegex = String.format("(\\*|%s)=%s", loggerNameRegex, loggerLevelRegex);
//         return String.format("%s(,%s)*", loggerLevelSpecRegex, loggerLevelSpecRegex);
//     }
// 
//     @Override
//     public void validate(String name, String loggerLevelSpecs) throws ParameterException {
//         if (!loggerLevelSpecs.matches(LOGGER_LEVEL_SPECS_REGEX)) {
//             String message = String.format("invalid logger level specification: %s %s", name, loggerLevelSpecs);
//             throw new ParameterException(message);
//         }
//     }
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/validator/UriValidator.java
// public class UriValidator implements IParameterValidator {
// 
//     @Override
//     public void validate(String name, String value) throws ParameterException {
//         try {
//             new URI(value);
//         } catch (URISyntaxException error) {
//             String message = String.format("invalid URI: %s %s", name, value);
//             throw new ParameterException(message, error);
//         }
//     }
// 
// }


import com.beust.jcommander.Parameter;
import com.vlkan.hrrs.commons.jcommander.JCommanderConfig;
import com.vlkan.hrrs.commons.jcommander.JCommanderConfigs;
import com.vlkan.hrrs.commons.jcommander.validator.LoggerLevelSpecsValidator;
import com.vlkan.hrrs.commons.jcommander.validator.UriValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;

    @Parameter(
            names = {"--loggerLevelSpecs", "-L"},
            validateWith = LoggerLevelSpecsValidator.class,
            description = "comma-separated list of loggerName=loggerLevel pairs")
    private String loggerLevelSpecs = "*=warn,com.vlkan.hrrs=info";

    public String getLoggerLevelSpecs() {
        return loggerLevelSpecs;
    }

    @Parameter(
            names = {"--help", "-h"},
            help = true,
            description = "display this help and exit")
    private boolean help;

    @Override
    public boolean isHelp() {
        return help;
    }

    public void dump() {
        LOGGER.debug("inputUri = {}", inputUri);
        LOGGER.debug("outputUri = {}", outputUri);
        LOGGER.debug("scriptUri = {}", scriptUri);
        LOGGER.debug("loggerLevelSpecs={}", loggerLevelSpecs);
    }

    public static Config of(String[] args) {
// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/JCommanderConfig.java
// public interface JCommanderConfig {
// 
//     boolean isHelp();
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/JCommanderConfigs.java
// public enum JCommanderConfigs {;
// 
//     public static <C extends JCommanderConfig> C create(String[] args, C config) {
//         JCommander jCommander = null;
//         try {
//             jCommander = new JCommander(config);
//             jCommander.parse(args);
//         } catch (ParameterException error) {
//             System.err.println(error.getMessage());
//             System.err.println("Run with --help, -h for the list of available parameters.");
//             System.exit(1);
//         }
//         if (config.isHelp()) {
//             jCommander.usage();
//             System.exit(0);
//         }
//         return config;
//     }
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/validator/LoggerLevelSpecsValidator.java
// public class LoggerLevelSpecsValidator implements IParameterValidator {
// 
//     private static final String LOGGER_LEVEL_SPECS_REGEX = createLoggerLevelSpecsRegex();
// 
//     private static String createLoggerLevelSpecsRegex() {
//         String packageNameRegex = "[\\p{L}_$][\\p{L}\\p{N}_$]*";
//         String loggerNameRegex = String.format("%s(\\.%s)*", packageNameRegex, packageNameRegex);
//         String loggerLevelRegex = "(trace|debug|info|warn|error)";
//         String loggerLevelSpecRegex = String.format("(\\*|%s)=%s", loggerNameRegex, loggerLevelRegex);
//         return String.format("%s(,%s)*", loggerLevelSpecRegex, loggerLevelSpecRegex);
//     }
// 
//     @Override
//     public void validate(String name, String loggerLevelSpecs) throws ParameterException {
//         if (!loggerLevelSpecs.matches(LOGGER_LEVEL_SPECS_REGEX)) {
//             String message = String.format("invalid logger level specification: %s %s", name, loggerLevelSpecs);
//             throw new ParameterException(message);
//         }
//     }
// 
// }
// 
// Path: commons/src/main/java/com/vlkan/hrrs/commons/jcommander/validator/UriValidator.java
// public class UriValidator implements IParameterValidator {
// 
//     @Override
//     public void validate(String name, String value) throws ParameterException {
//         try {
//             new URI(value);
//         } catch (URISyntaxException error) {
//             String message = String.format("invalid URI: %s %s", name, value);
//             throw new ParameterException(message, error);
//         }
//     }
// 
// }


// Path: distiller/src/main/java/com/vlkan/hrrs/distiller/cli/Config.java
import com.beust.jcommander.Parameter;
import com.vlkan.hrrs.commons.jcommander.JCommanderConfig;
import com.vlkan.hrrs.commons.jcommander.JCommanderConfigs;
import com.vlkan.hrrs.commons.jcommander.validator.LoggerLevelSpecsValidator;
import com.vlkan.hrrs.commons.jcommander.validator.UriValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;


    @Parameter(
            names = {"--loggerLevelSpecs", "-L"},
            validateWith = LoggerLevelSpecsValidator.class,
            description = "comma-separated list of loggerName=loggerLevel pairs")
    private String loggerLevelSpecs = "*=warn,com.vlkan.hrrs=info";

    public String getLoggerLevelSpecs() {
        return loggerLevelSpecs;
    }

    @Parameter(
            names = {"--help", "-h"},
            help = true,
            description = "display this help and exit")
    private boolean help;

    @Override
    public boolean isHelp() {
        return help;
    }

    public void dump() {
        LOGGER.debug("inputUri = {}", inputUri);
        LOGGER.debug("outputUri = {}", outputUri);
        LOGGER.debug("scriptUri = {}", scriptUri);
        LOGGER.debug("loggerLevelSpecs={}", loggerLevelSpecs);
    }

    public static Config of(String[] args) {
        return JCommanderConfigs.create(args, new Config());