Load the config parameters from the command line

@param cmd command line options
@return config, the command line config
509797
private static Config commandLineConfigs(CommandLine cmd) {
    String cluster = getOptionValue(cmd, CliArgs.CLUSTER);
    String role = getOptionValue(cmd, CliArgs.ROLE);
    String environ = getOptionValue(cmd, CliArgs.ENVIRONMENT);
    String topologyName = getOptionValue(cmd, CliArgs.TOPOLOGY_NAME);
    Boolean verbose = hasOption(cmd, CliArgs.VERBOSE);

    Config.Builder commandLineConfig = Config.newBuilder()
        .put(Key.CLUSTER, cluster)
        .put(Key.ROLE, role)
        .put(Key.ENVIRON, environ)
        .put(Key.TOPOLOGY_NAME, topologyName)
        .put(Key.VERBOSE, verbose);

    return commandLineConfig.build();
  }
230128
private void doit(String[] args)
    {
        try
        {
            // load parameters from the commandline
            loadParameters(args);

            // Try to load the private key
            importKeyPair();
        }
        catch (Exception e)
        {
            System.out.println("Exception: " + e.getMessage());
            e.printStackTrace();
            
            System.exit(23);
        }
    }
478306
public SyncOptimizeConfig processCommandLine(String[] args) {
        SyncOptimizeConfig config = null;
        try {
            config = processOptions(args);
        } catch (ParseException e) {
            printHelp(e.getMessage());
        }
        return config;
    }
935243
public static String getConfigParam(String key, String defaultValue) {
		if (config == null) {
			init(null);
		}
		if (StringUtils.isBlank(key)) {
			return defaultValue;
		}
		String keyVar = key.replaceAll("\\.", "_");
		String env = System.getenv(keyVar) == null ? System.getenv(PARA + "_" + keyVar) : System.getenv(keyVar);
		String sys = System.getProperty(key, System.getProperty(PARA + "." + key));
		if (!StringUtils.isBlank(sys)) {
			return sys;
		} else if (!StringUtils.isBlank(env)) {
			return env;
		} else {
			return (!StringUtils.isBlank(key) && config.hasPath(key)) ? config.getString(key) : defaultValue;
		}
	}
251256
def getCmdParams(cmd, request, **fields):
    """"""
    drCode = None
    params = None
    drAppId = None
    # Fetch the parameters if cmd is found in dict
    if isinstance(cmd, int):
        drCode = cmd    # Enable to craft commands with non standard code
        if cmd in DR_cmd_def:
            params = DR_cmd_def[drCode]
        else:
            params = ('Unknown', 'UK', {0: (128, 0)})
            warning(
                'No Diameter command with code %d found in DR_cmd_def dictionary' %  # noqa: E501
                cmd)
    else:  # Assume command is a string
        if len(cmd) > 3:     # Assume full command name given
            fpos = 0
        else:         # Assume abbreviated name is given and take only the first two letters  # noqa: E501
            cmd = cmd[:2]
            fpos = 1
        for k, f in DR_cmd_def.items():
            if f[fpos][:len(
                    cmd)] == cmd:   # Accept only a prefix of the full name
                drCode = k
                params = f
                break
        if not drCode:
            warning(
                'Diameter command with name %s not found in DR_cmd_def dictionary.' %  # noqa: E501
                cmd)
            return (fields, 'Unknown')
    # The drCode is set/overridden in any case
    fields['drCode'] = drCode
    # Processing of drAppId
    if 'drAppId' in fields:
        val = fields['drAppId']
        if isinstance(val, str):   # Translate into application Id code
            found = False
            for k, v in six.iteritems(AppIDsEnum):
                if v.find(val) != -1:
                    drAppId = k
                    fields['drAppId'] = drAppId
                    found = True
                    break
            if not found:
                del(fields['drAppId'])
                warning(
                    'Application ID with name %s not found in AppIDsEnum dictionary.' %  # noqa: E501
                    val)
                return (fields, 'Unknown')
        else:   # Assume type is int
            drAppId = val
    else:  # Application Id shall be taken from the params found based on cmd
        drAppId = next(iter(params[2]))   # The first record is taken
        fields['drAppId'] = drAppId
    # Set the command name
    name = request and params[0] + '-Request' or params[0] + '-Answer'
    # Processing of flags (only if not provided manually)
    if 'drFlags' not in fields:
        if drAppId in params[2]:
            flags = params[2][drAppId]
            fields['drFlags'] = request and flags[0] or flags[1]
    return (fields, name)
81569
def getParameter(self, objID, param):
        
        self._connection._beginMessage(
            self._cmdGetID, tc.VAR_PARAMETER, objID, 1 + 4 + len(param))
        self._connection._packString(param)
        result = self._connection._checkResult(
            self._cmdGetID, tc.VAR_PARAMETER, objID)
        return result.readString()
605959
private void loadParameters(String[] args)
    {
        for (int i = 0; (i < args.length) && args[i].startsWith("-"); i++)
        {
            String parameterName = args[i];
            if (parameterName.equalsIgnoreCase("-key"))
                privateKeyFile = new File(args[++i]);
            else if (parameterName.equalsIgnoreCase("-cert"))
                certFile = new File(args[++i]);
        else if (parameterName.equalsIgnoreCase("-keystore"))
                keyStoreFile = new File(args[++i]);
            else if (parameterName.equalsIgnoreCase("-storetype"))
                keyStoreType = args[++i];
            else if (parameterName.equalsIgnoreCase("-alias"))
                alias = args[++i];
            else if (parameterName.equalsIgnoreCase("-provider"))
                providerClassName = args[++i];
            else
            {
                System.err.println("Illegal parameter: " + parameterName);
                usage();
            }
        }

        // Check that mandatory fields have been populated
        if (privateKeyFile == null || certFile == null)
        {
            usage();
        }

        keyStorePassword = Password.getPassword("jetty.ssl.password",null,null);
        keyPassword = Password.getPassword("jetty.ssl.keypassword",
                                           null,
                                           keyStorePassword.toString());
    }
985502
protected static String tryCommands (String[] cmds)
    {
        if (cmds == null) {
            return null;
        }

        String output;

        for (int ii = 0; ii < cmds.length; ii++) {
            output = runCommand(cmds[ii]);
            if (output != null) {
                return output;
            }
        }

        return null;
    }
1241530
public CommandLine parse(String[] args) throws ParseException {
        // create the command line parser
        GnuParser parser = new GnuParser();
        Options buildCommandLineOptions = buildCommandLineOptions();
        CommandLine cmd = null;
        try {
            cmd = parser.parse(buildCommandLineOptions, args);
            if (cmd.getOptions().length == 0 || cmd.hasOption("h")) {
                printHelp(buildCommandLineOptions);
                return null;
            }
            if (cmd.getArgList().isEmpty()) {
                throw new MissingOptionException("The 'inputPage' is mandatory! No page to run given");
            }
            return cmd;
        } catch (MissingOptionException e) {
            if (args == null || args.length == 0) {
                logger.debug("option --help has been set. Ignoring Missing Option exception");
                printHelp(buildCommandLineOptions);
                return cmd;
            }
            for (String arg : args) {
                if (StringUtils.equals("-h", arg) || StringUtils.equals("--help", arg)) {
                    logger.debug("option --help has been set. Ignoring Missing Option exception");
                    printHelp(buildCommandLineOptions);
                    return null;
                }
            }
            handleParseException(buildCommandLineOptions, e);
            throw e;
        } catch (ParseException e) {
            handleParseException(buildCommandLineOptions, e);
            throw e;
        }
    }
225663
protected List<String> getOptionsByCommand(String command){
        String rawOption = commands.get(command);
        String[] options = rawOption.split(CoreConstants.COMMA);
        return Arrays.asList(options);
    }
516430
public SyncToolConfig processCommandLine(String[] args) {
        SyncToolConfig config = null;
        try {
            config = processConfigFileOptions(args);
        } catch (ParseException e) {
            printHelp(e.getMessage());
        }
        return config;
    }
406940
private CommandOutput<?, ?> executePreparedSql(List<Command> cmds) {
    String query = null;
    List<String> queryParameters = null;
    int fetchSize = 0;

    for (Command cmd : cmds) {
      if (cmd instanceof JdbcCommand) {
        JdbcCommandType type = (JdbcCommandType) cmd.getCommandType();
        switch (type) {
          case QUERY:
            query = cmd.getParams().get(0);
            break;
          case QUERYPARAMS:
            queryParameters = cmd.getParams();
            break;
          case FETCHSIZE:
            fetchSize = Integer.parseInt(cmd.getParams().get(0));
            break;
          default:
            this.log.error("Command " + type.toString() + " not recognized");
            break;
        }
      }
    }

    this.log.info("Executing query:" + query);
    ResultSet resultSet = null;
    try {
      this.jdbcSource = createJdbcSource();
      if (this.dataConnection == null) {
        this.dataConnection = this.jdbcSource.getConnection();
      }

      PreparedStatement statement =
          this.dataConnection.prepareStatement(query, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

      int parameterPosition = 1;
      if (queryParameters != null && queryParameters.size() > 0) {
        for (String parameter : queryParameters) {
          statement.setString(parameterPosition, parameter);
          parameterPosition++;
        }
      }
      if (fetchSize != 0) {
        statement.setFetchSize(fetchSize);
      }
      final boolean status = statement.execute();
      if (status == false) {
        this.log.error("Failed to execute sql:" + query);
      }
      resultSet = statement.getResultSet();

    } catch (Exception e) {
      this.log.error("Failed to execute sql:" + query + " ;error-" + e.getMessage(), e);
    }

    CommandOutput<JdbcCommand, ResultSet> output = new JdbcCommandOutput();
    output.put((JdbcCommand) cmds.get(0), resultSet);
    return output;
  }
1134212
private ProxyDestroyParams getProxyDestroyParamsFromCommandLine(
    CommandLine commandLine) {

    ProxyDestroyParams params = new ProxyDestroyParams();

    if (commandLineHasOption(ProxyDestroyOptions.DRY)) {
      params.setDryRun(true);
    }

    if (commandLineHasOption(ProxyDestroyOptions.FILE)) {
      params.setProxyFile(getOptionValue(ProxyDestroyOptions.FILE));
    }

    return params;
  }
751828
public Settings load(String file, CommandBuilder builder) throws CommandLineException {

		Scanner scanner = null;
		try {

			File config = new File(file);
			Assert.isTrue(config.exists(), "File '" + file + "' does not exist");
			Assert.isFalse(config.isDirectory(), "File '" + file + "' is a directory");
			Assert.isTrue(config.canRead(), "File '" + file + "' cannot be read");

			scanner = new Scanner(config);

			ArrayList<String> list = new ArrayList<>();
			while (scanner.hasNextLine()) {
				list.add(scanner.nextLine());
			}

			return parse(list, builder);
		}
		catch (FileNotFoundException e) {

			log.error("File not found: " + e.getMessage());
			throw new CommandLineException("File: '" + file + "', not found!");
		}
		finally {

			if (scanner != null) {
				scanner.close();
			}
		}
	}
1008334
def load_cmd_line_settings(options)
      @login = options[:login] if options[:login]
      @password = options[:password] if options[:password]
      @cache_file_path = options[:cache_file_path] if options[:cache_file_path]
      @auto_check = options[:auto_check] if options[:auto_check]
    end
1248407
public function inform($cmd, $params = [])
    {
        switch ($cmd) {
          case 'label': // module's short name for menu
            if (!empty($this->params['label'])) {
                $label = $this->params['label'];
                // try to translate label
                $tcCat = TranslationsBuilder::getBaseTransCategory($this);
                $tc = "{$tcCat}/module";
                if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) {
                    $label = Yii::t($tc, $this->params['label']);
                }
                return $label;
            } else {
                //return false;
                try {
                    $ms = Yii::$app->i18n->getMessageSource(static::$tc);
                } catch(InvalidConfigException $ex) {
                    $ms = false;
                }
                return ($ms ? Yii::t(static::$tc, 'Module') : 'Module') . ' ' . $this->uniqueId;
            }
            break;
          case 'sitetree-params-action': // return action in route format
            //if (empty($params['module_full_id'])) return false;
            if (!empty($this->params['sitetree-params-action'])) return $this->params['sitetree-params-action'];
            break;
//todo
        }
        return null;
    }
580163
public Map<String, Object> executeCdpCommand(String commandName, Map<String, Object> parameters) {
    Objects.requireNonNull(commandName, "Command name must be set.");
    Objects.requireNonNull(parameters, "Parameters for command must be set.");

    @SuppressWarnings("unchecked")
    Map<String, Object> toReturn = (Map<String, Object>) getExecuteMethod().execute(
        ChromeDriverCommand.EXECUTE_CDP_COMMAND,
        ImmutableMap.of("cmd", commandName, "params", parameters));

    return ImmutableMap.copyOf(toReturn);
  }