@SuppressWarnings("unchecked")
    public static JobParamsInfo parseArgs(String[] args) throws Exception {
        if (args.length == 1 && args[0].endsWith(".json")) {
            args = parseJson(args);
        }
        OptionParser optionParser = new OptionParser(args);
        Options launcherOptions = optionParser.getOptions();
        List<String> programExeArgList = optionParser.getProgramExeArgList();
        String[] execArgs = programExeArgList.toArray(new String[0]);

        String name = launcherOptions.getName();
        String mode = launcherOptions.getMode();
        String localPluginRoot = launcherOptions.getLocalSqlPluginPath();
        String flinkConfDir = launcherOptions.getFlinkconf();
        String flinkJarPath = launcherOptions.getFlinkJarPath();
        String yarnConfDir = launcherOptions.getYarnconf();
        String udfJar = launcherOptions.getAddjar();
        String queue = launcherOptions.getQueue();
        String pluginLoadMode = launcherOptions.getPluginLoadMode();
        String addShipfile = launcherOptions.getAddShipfile();
        String dirtyStr = launcherOptions.getDirtyProperties();

        String yarnSessionConf = URLDecoder.decode(launcherOptions.getYarnSessionConf(), Charsets.UTF_8.toString());
        Properties yarnSessionConfProperties = PluginUtil.jsonStrToObject(yarnSessionConf, Properties.class);

        String confProp = URLDecoder.decode(launcherOptions.getConfProp(), Charsets.UTF_8.toString());
        Properties confProperties = PluginUtil.jsonStrToObject(confProp, Properties.class);
        Map<String, Object> dirtyProperties = PluginUtil.jsonStrToObject(Objects.isNull(dirtyStr) ?
               DirtyDataManager.buildDefaultDirty() : dirtyStr, Map.class);

        return JobParamsInfo.builder()
                .setExecArgs(execArgs)
                .setName(name)
                .setMode(mode)
                .setUdfJar(udfJar)
                .setLocalPluginRoot(localPluginRoot)
                .setFlinkConfDir(flinkConfDir)
                .setYarnConfDir(yarnConfDir)
                .setConfProperties(confProperties)
                .setYarnSessionConfProperties(yarnSessionConfProperties)
                .setFlinkJarPath(flinkJarPath)
                .setPluginLoadMode(pluginLoadMode)
                .setQueue(queue)
                .setDirtyProperties(dirtyProperties)
                .setAddShipfile(addShipfile)
                .build();
    }
Date: 2017/2/20
Company: www.dtstack.com
@author xuchao
launcher/src/main/java/com/dtstack/flink/sql/launcher/LauncherMain.java