package io.github.interestinglab.waterdrop.config;


import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.io.File;

import io.github.interestinglab.waterdrop.config.SparkDriverSettings;


public class ExposeSparkDriverConf {

    public static List<String> splitKey(String key) {
        List<String> keys = new LinkedList<>();
        int index = 0;
        for (int i = 0; i < key.length(); i++) {
            char symbol = key.charAt(i);
            if (symbol >= 'A' && symbol <= 'Z') {
                keys.add(key.substring(index, i).toLowerCase());
                index = i;
            }
        }

        keys.add(key.substring(index).toLowerCase());

        if (keys.get(0).equals("extra")) {
            return keys.subList(1, keys.size());
        }
        return keys;
    }

    public static void main(String[] args) throws Exception {
        Config appConfig = ConfigFactory.parseFile(new File(args[0]))
                .resolve(ConfigResolveOptions.defaults().setAllowUnresolved(true))
                .resolveWith(ConfigFactory.systemProperties(), ConfigResolveOptions.defaults().setAllowUnresolved(true));

        String driverPrefix = "spark.driver.";
        Config sparkConfig = appConfig.getConfig("spark");

        if (!TypesafeConfigUtils.hasSubConfig(sparkConfig, driverPrefix)) {
            System.out.println("");
        } else {
            Config sparkDriverConfig = TypesafeConfigUtils.extractSubConfig(sparkConfig, driverPrefix, true);
            StringBuilder stringBuilder = new StringBuilder();
            for (Map.Entry<String, ConfigValue> entry : sparkDriverConfig.entrySet()) {
                String key = entry.getKey();
                SparkDriverSettings settings = SparkDriverSettings.fromProperty(key);
                if (settings != null) {
                    String conf = String.format("%s=%s", settings.option, entry.getValue().unwrapped());
                    stringBuilder.append(conf);
                }
            }

            System.out.println(stringBuilder.toString());
        }
    }
}

@@ -67,762 +67,73 @@
 til.
-LinkedList;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.io.File;%0A%0Aimport io.github.interestinglab.waterdrop.config.SparkDriverSettings;%0A%0A%0Apublic class ExposeSparkDriverConf %7B%0A%0A    public static List%3CString%3E splitKey(String key) %7B%0A        List%3CString%3E keys = new LinkedList%3C%3E();%0A        int index = 0;%0A        for (int i = 0; i %3C key.length(); i++) %7B%0A            char symbol = key.charAt(i);%0A            if (symbol %3E= 'A' && symbol %3C= 'Z') %7B%0A                keys.add(key.substring(index, i).toLowerCase());%0A                index = i;%0A            %7D%0A        %7D%0A%0A        keys.add(key.substring(index).toLowerCase());%0A%0A        if (keys.get(0).equals(%22extra%22)) %7B%0A            return keys.subList(1, keys.size());%0A        %7D%0A        return keys;%0A    %7D
+Map;%0Aimport java.io.File;%0A%0A%0Apublic class ExposeSparkDriverConf %7B%0A
 %0A%0A  
@@ -1189,13 +1189,15 @@
 at(%22
+ 
 %25s=%25s
+ 
 %22, s

Remove useless code