Compiles options in a command

@param ICommand $command The command to compile
@param IRequest $request The user request
517857
protected function compileOptions(ICommand $command, IRequest $request)
    {
        foreach ($command->getOptions() as $option) {
            $shortNameIsSet = $option->getShortName() === null ?
                    false :
                    $request->optionIsSet($option->getShortName());
            $longNameIsSet = $request->optionIsSet($option->getName());

            // All options are optional (duh)
            if ($shortNameIsSet || $longNameIsSet) {
                if ($longNameIsSet) {
                    $value = $request->getOptionValue($option->getName());
                } else {
                    $value = $request->getOptionValue($option->getShortName());
                }

                if (!$option->valueIsPermitted() && $value !== null) {
                    throw new RuntimeException("Option \"{$option->getName()}\" does not permit a value");
                }

                if ($option->valueIsRequired() && $value === null) {
                    throw new RuntimeException("Option \"{$option->getName()}\" requires a value");
                }

                if ($option->valueIsOptional() && $value === null) {
                    $value = $option->getDefaultValue();
                }

                $command->setOptionValue($option->getName(), $value);
            } elseif ($option->valueIsPermitted()) {
                // Set the value for the option to its default value, if values are permitted
                $command->setOptionValue($option->getName(), $option->getDefaultValue());
            }
        }
    }
1040920
protected function compile(array &$aClientConfig, array &$aRequestOptions)
    {
        parent::compile($aClientConfig, $aRequestOptions);
        $aRequestOptions['form_params'] = $this->aFormParams;
    }
946966
public function setup($handler, ICommand $command) {
        return $this->container->callMethod($handler, 'setup', [
            'command' => $command,
            'cmd' => $command
        ]);
    }
829356
public function format(ICommand $command) : string
    {
        $text = $command->getName() . ' ';

        // Output the options
        foreach ($command->getOptions() as $option) {
            $text .= $this->formatOption($option) . ' ';
        }

        /** @var Argument[] $requiredArguments */
        $requiredArguments = [];
        /** @var Argument[] $optionalArguments */
        $optionalArguments = [];
        /** @var Argument $arrayArgument */
        $arrayArgument = null;

        // Categorize each argument
        foreach ($command->getArguments() as $argument) {
            if ($argument->isRequired() && !$argument->isArray()) {
                $requiredArguments[] = $argument;
            } elseif ($argument->isOptional() && !$argument->isArray()) {
                $optionalArguments[] = $argument;
            }

            if ($argument->isArray()) {
                $arrayArgument = $argument;
            }
        }

        // Output the required arguments
        foreach ($requiredArguments as $argument) {
            $text .= $argument->getName() . ' ';
        }

        // Output the optional arguments
        foreach ($optionalArguments as $argument) {
            $text .= "[{$argument->getName()}] ";
        }

        // Output the array argument
        if ($arrayArgument !== null) {
            $text .= $this->formatArrayArgument($arrayArgument);
        }

        return trim($text);
    }
977055
protected function _execute($command) {
		try {
			if (!$class = $this->_instance($command)) {
				return false;
			}
		} catch (ClassNotFoundException $e) {
			return false;
		}
		$data = [];
		$params = $class->invokeMethod('_params');

		foreach ($params as $param) {
			$data[$param] = $class->invokeMethod("_{$param}", [$this->request]);
		}

		if ($message = $class->invokeMethod('_save', [$data])) {
			$this->out($message);
			return true;
		}
		return false;
	}
780743
public function rawcommand($command)
    {
        if (preg_match('/(.+)[\n]$/', $command)) {
            $this->socket->send($command);
        } else {
            $this->socket->send($command.PHP_EOL);
        }
    }
170880
protected function _commandDelete($command)
    {
        $entity = $this->getController()->getItem();

        $command->append(array('label' => AnTranslator::_('LIB-AN-ACTION-DELETE')))
        ->href(route($entity->getURL()))
        ->setAttribute('data-action', 'delete')
        ->setAttribute('data-redirect', route('index.php?option=com_locations&view=locations'))
        ->class('action-delete');
    }
301137
public function runCommand(Command $command, array $parameters = [], OutputInterface $output = null)
    {
        $parameters['command'] = $command->getName();
        $input = new ArrayInput($parameters);

        if ($output === null) {
            $output = new NullOutput();
        }

        $command->setApplication(new SymfonyConsoleApplication());

        return $command->run($input, $output);
    }
1170837
public static function convertRequestToCurlCommand(Request $request)
    {
        $message = 'curl -X'.\strtoupper($request->getMethod()).' ';
        $message .= '\'http://'.$request->getConnection()->getHost().':'.$request->getConnection()->getPort().'/';
        $message .= $request->getPath();

        $query = $request->getQuery();
        if (!empty($query)) {
            $message .= '?'.\http_build_query($query);
        }

        $message .= '\'';

        $data = $request->getData();
        if (!empty($data)) {
            $message .= ' -d \''.JSON::stringify($data).'\'';
        }

        return $message;
    }
875999
protected function createRequest(CommandInterface $command)
    {
        $operation = $command->getOperation();
        $client = $command->getClient();
        $options = $command[AbstractCommand::REQUEST_OPTIONS] ?: array();

        // If the command does not specify a template, then assume the base URL of the client
        if (!($uri = $operation->getUri())) {
            return $client->createRequest($operation->getHttpMethod(), $client->getBaseUrl(), null, null, $options);
        }

        // Get the path values and use the client config settings
        $variables = array();
        foreach ($operation->getParams() as $name => $arg) {
            if ($arg->getLocation() == 'uri') {
                if (isset($command[$name])) {
                    $variables[$name] = $arg->filter($command[$name]);
                    if (!is_array($variables[$name])) {
                        $variables[$name] = (string) $variables[$name];
                    }
                }
            }
        }

        return $client->createRequest($operation->getHttpMethod(), array($uri, $variables), null, null, $options);
    }
341755
public static function interleaved(CommandInterface $command, $prefix)
    {
        if ($arguments = $command->getArguments()) {
            $length = count($arguments);

            for ($i = 0; $i < $length; $i += 2) {
                $arguments[$i] = "$prefix{$arguments[$i]}";
            }

            $command->setRawArguments($arguments);
        }
    }
410218
public function fire(Command $command)
    {
        $this->command = $command;

        if ($command->option('verbose')) {
            $command->blockMessage('Requirements', 'Checking System Requirements ...', 'comment');
        }

        $this->checkPHPVersion();
        $this->checkExtensions();

        $this->showResults();
    }
821528
private function execute(CommandInterface $command)
    {
        $handler = $this->locator->locate($command);

        if (!$handler->supports($command)) {
            throw new InvalidCommandException(sprintf('The registered command handler doesn\'t support "%s"', get_class($command)));
        }

        $this->executing = true;

        $handler->execute($command);

        $this->executing = false;
    }
933550
public function compile($force = false)
    {
        $this->commandCaller->compile($this->configFile, $force, $this->target);
    }
530396
public function fire(Command $command)
    {
        if ($command->option('verbose')) {
            $command->call('key:generate');
            $command->call('api:key-generate');

            return;
        }
        $command->callSilent('key:generate');
        $command->callSilent('api:key-generate');
    }
919250
protected function runCommand(ICommand $command, $isolate = true) {
        try {
            if ( ! $command->isGlobal()) {
                $this->commandExecutionLock->lockCommand($command, $this->getAllowParallel());
            }

            if ($isolate) {
                $input = clone $this->input;
                $output = clone $this->output;
            } else {
                $input = $this->input;
                $output = $this->output;
            }

            $input->setCommand($command);

            return $this->commandInvoker->run(
                $command->getHandler(), $input, $output, $this
            );
        } catch (Exception $ex) {
            if ($this->getCatchErrors()) {
                $widget = new ExceptionWidget($this->input, $this->output);
                $widget->render($ex);
            } else {
                throw $ex;
            }
        }
    }
547742
function compile(context, commands) {
    let ii, cmd, limitOptions;

    // log.debug('limit: in-compile cmds:', commands);

    // look for the limit commands within the commands
    for (ii = commands.length - 1; ii >= 0; ii--) {
        cmd = commands[ii];
        if (cmd[0] === LIMIT) {
            // cmdLimit = cmd;
            limitOptions = {
                offset: context.valueOf(cmd[2]),
                limit: context.valueOf(cmd[1])
            };
            commands.splice(ii, 1);
        } else if (limitOptions && cmd[0] === ENTITY_FILTER) {
            // set the options object of the entityFilter command
            if (limitOptions) {
                cmd[3] = { ...cmd[3], ...limitOptions };
            }
            limitOptions = null;
        }
    }

    // if we still have an open limit and no entity filter was found, add one
    if (limitOptions) {
        commands.unshift([ENTITY_FILTER, null, null, limitOptions]);
    }

    return commands;
}