Apply optional parameters for each command

@param   array   $params   The parameters
@param   string  $cmdName  The command name

@return array

@see https://developers.google.com/drive/v3/reference/files
@see \Google_Service_Drive_Resource_Files
436840
protected function applyDefaultParams($params, $cmdName)
    {
        if (isset($this->defaultParams[$cmdName]) && is_array($this->defaultParams[$cmdName])) {
            return array_replace($this->defaultParams[$cmdName], $params);
        } else {
            return $params;
        }
    }
183429
protected static function _buildWriteParams($params = array()) {
		$writeParams['equalKeysOnly'] = (
			isset($params['equalKeysOnly']) &&
			empty($params['equalKeysOnly']) ? false : true
		);

		return $writeParams;
	}
860577
public function matchCommandName(array $args) {
        $commandName = null;

        if (array_has($args, 'arguments')) {
            $commandName = (string) array_shift($args['arguments']);
        }

        if ( ! $commandName || str_starts_with($commandName, '-')) {
            throw new MissingCommandNameException(
                'You must provide a valid command name.'
            );
        }

        return [$commandName, $args];
    }
995247
public static function make( $cmd, $params )
	{
		if ( !is_array( $params ) )
		{
			$params = array( $params );
		}
		
		$forge = new static;
		
		if ( !method_exists( $forge, $cmd ) )
		{
			throw new CCException( "CCForge_Php - Command could not be found." );
		}
		
		return call_user_func_array( array( $forge, $cmd ), $params );
	}
974532
protected static function parseParameters($param)
    {
        $result = array();
        $parts = explode('=', trim($param));
        $key = array_shift($parts);
        while (!empty($parts)) {
            $value = array_shift($parts);
            while (('"' == $value{0} || "'" == $value{0}) && false == strrpos($value, $value{0}) && !empty($parts)) {
                $value .= '=' . array_shift($parts);
            }
            if (!empty($value) && !empty($parts) && $pos = strrpos($value, ' ')) {
                $result[$key] = self::__compileVar(trim(substr($value, 0, $pos), '\'"'));
                $key = substr($value, $pos + 1);
            } else {
                $result[$key] = self::__compileVar(trim($value, '\'"'));
            }
        }

        return $result;
    }
57178
protected function call($command, $params, $data = [], $options = [])
    {
        $uri = $this->getRequestURI($command);
        $body = $this->getRequestBody($params, $data, $options);
        $xml = $this->client->post($uri, $body); // Make the request to web service
        return $this->factory->createResponse($xml, $this->module, $command);
    }
1324448
public function visit(
        CommandInterface $command,
        RequestInterface $request,
        Parameter $param
    ) {
        $value = $command[$param->getName()];

        return $request->withHeader($param->getWireName(), $param->filter($value));
    }
641463
protected function applyActionsBuilderDefaults(array $params)
    {
        if (!array_key_exists('namespace_prefix', $params) || !array_key_exists('bundle_name', $params)) {
            return $params;
        }

        $routeBase = $params['namespace_prefix'].'_'.$params['bundle_name'].'_'.$this->getBaseGeneratorName();

        if (array_key_exists('object_actions', $params) && is_array($params['object_actions'])) {
            foreach ($params['object_actions'] as $name => $config) {
                $baseKey = 'object_actions.'.$name;

                if (is_array($config) && array_key_exists('route', $config) && $config['route'] === 'inject_object_defaults') {
                    $customized = $params['object_actions'][$name];
                    unset($customized['route']);

                    $params['object_actions'][$name] = $this->recursiveReplace(array(
                        'route'         => $routeBase.'_object',
                        'label'         => $baseKey.'.label',
                        'csrfProtected' => true,
                        'params'        => array(
                            'pk'        => '{{ '.$this->getBaseGeneratorName().'.id }}',
                            'action'    => $name,
                        ),
                        'options'       => array(
                            'title'     => $baseKey.'.title',
                            'success'   => $baseKey.'.success',
                            'error'     => $baseKey.'.error',
                        ),
                    ), $customized);
                }
            }
        }

        if (array_key_exists('batch_actions', $params) && is_array($params['batch_actions'])) {
            foreach ($params['batch_actions'] as $name => $config) {
                $baseKey = 'batch_actions.'.$name;

                if (is_array($config) && array_key_exists('route', $config) && $config['route'] === 'inject_batch_defaults') {
                    $params['batch_actions'][$name] = $this->recursiveReplace($params['batch_actions'][$name], array(
                        'route'         => $routeBase.'_batch',
                        'label'         => $baseKey.'.label',
                        'csrfProtected' => true,
                        'params'        => array(
                            'action'    => $name,
                        ),
                        'options'       => array(
                            'title'     => $baseKey.'.title',
                            'success'   => $baseKey.'.success',
                            'error'     => $baseKey.'.error',
                            'notfound'  => $baseKey.'.notfound',
                        ),
                    ));
                }
            }
        }

        return $params;
    }
883551
public function executeJson($command, $params = null)
    {
        return json_decode($this->execute($command, $params), true);
    }
207426
private function parse_param_array($param, $check=false, $default = ""){
		if (gettype($param) == 'string')
			$param = explode($this->headerDelimiter, $param);
				
		if ($check){
			for ($i=0; $i < sizeof($param); $i++) { 
				if (!array_key_exists($param[$i],$check))
					$param[$i] = $default;
			}
		}
		return $param;
	}
879850
public function subCommands($commandName)
    {
        $Shell = $this->getShell($commandName);

        if (!$Shell) {
            return [];
        }

        $taskMap = $this->Tasks->normalizeArray((array)$Shell->tasks);
        $return = array_keys($taskMap);
        $return = array_map('Cake\Utility\Inflector::underscore', $return);

        $shellMethodNames = ['main', 'help', 'getOptionParser', 'initialize', 'runCommand'];

        $baseClasses = ['Object', 'Shell', 'AppShell'];

        $Reflection = new ReflectionClass($Shell);
        $methods = $Reflection->getMethods(ReflectionMethod::IS_PUBLIC);
        $methodNames = [];
        foreach ($methods as $method) {
            $declaringClass = $method->getDeclaringClass()->getShortName();
            if (!in_array($declaringClass, $baseClasses)) {
                $methodNames[] = $method->getName();
            }
        }

        $return = array_merge($return, array_diff($methodNames, $shellMethodNames));
        sort($return);

        return $return;
    }
318589
private function exec($command, $params = []) {
        if (in_array($command, $this->available_commands)) {
            // convert json to array then get the last messages info
            $output = json_decode($this->curl_get_contents($this->api . '/' . $command, $params), true);

            return $this->convertToObject($output);
        } else {
            echo 'command not found';
        }
    }
1114970
protected function parseParam($param, string $name)
    {
        if (is_iterable($param)) {
            foreach ($param as $key => $value) {
                $param[$key] = $this->parseParam($value, $name);
            }

            return $param;
        }

        if (is_string($param)) {
            $param = $this->config->getEnv($param);

            if (preg_match('#^\{\{([^{}]+)\}\}$#', $param, $matches)) {
                return '{'.$matches[1].'}';
            }
            if (preg_match('#^\{([^{}]+)\}$#', $param, $matches)) {
                return $this->traverseTree($name, $matches[1]);
            }

            return $param;
        }

        return $param;
    }
1129567
public function getParam(string $param)
    {
        if (! empty($this->match['params'][$param])) {
            return $this->match['params'][$param];
        }
    }
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);
  }
690549
public function prepare($cmd, array $params = array())
    {
        $args = array();
        $cells = array();

        foreach ($params as $ident => $value) {
            $ident = is_numeric($ident) ? "" : strtolower($ident) . Teamspeak::SEPARATOR_PAIR;

            if (is_array($value)) {
                $value = array_values($value);

                for ($i = 0; $i < count($value); $i++) {
                    if ($value[$i] === null) {
                        continue;
                    } elseif ($value[$i] === false) {
                        $value[$i] = 0x00;
                    } elseif ($value[$i] === true) {
                        $value[$i] = 0x01;
                    } elseif ($value[$i] instanceof AbstractNode) {
                        $value[$i] = $value[$i]->getId();
                    }

                    $cells[$i][] = $ident . StringHelper::factory($value[$i])->escape()->toUtf8();
                }
            } else {
                if ($value === null) {
                    continue;
                } elseif ($value === false) {
                    $value = 0x00;
                } elseif ($value === true) {
                    $value = 0x01;
                } elseif ($value instanceof AbstractNode) {
                    $value = $value->getId();
                }

                $args[] = $ident . StringHelper::factory($value)->escape()->toUtf8();
            }
        }

        foreach (array_keys($cells) as $ident) {
            $cells[$ident] = implode(Teamspeak::SEPARATOR_CELL, $cells[$ident]);
        }

        if (count($args)) {
            $cmd .= " " . implode(Teamspeak::SEPARATOR_CELL, $args);
        }
        if (count($cells)) {
            $cmd .= " " . implode(Teamspeak::SEPARATOR_LIST, $cells);
        }

        return trim($cmd);
    }
623676
protected function coreCommand($command, $core, $params = array())
    {
        $command = strtoupper($command);
        $params = array_merge($params, array('action' => $command, 'wt' => 'json'));
        $params[$command == 'CREATE' ? 'name' : 'core'] = $core;

        return $this->_sendRawGet($this->_constructUrl('admin/cores', $params));
    }