protected function compileArguments(ICommand $command, IRequest $request)
    {
        $argumentValues = $request->getArgumentValues();
        $commandArguments = $command->getArguments();

        if ($this->hasTooManyArguments($argumentValues, $commandArguments)) {
            throw new RuntimeException('Too many arguments');
        }

        $hasSetArrayArgument = false;

        foreach ($commandArguments as $argument) {
            if (count($argumentValues) === 0) {
                if (!$argument->isOptional()) {
                    throw new RuntimeException("Argument \"{$argument->getName()}\" does not have default value");
                }

                $command->setArgumentValue($argument->getName(), $argument->getDefaultValue());
            } else {
                if ($hasSetArrayArgument) {
                    throw new RuntimeException('Array argument must appear at end of list of arguments');
                }

                if ($argument->isArray()) {
                    // Add the rest of the values in the request to this argument
                    $restOfArgumentValues = [];

                    while (count($argumentValues) > 0) {
                        $restOfArgumentValues[] = array_shift($argumentValues);
                    }

                    $command->setArgumentValue($argument->getName(), $restOfArgumentValues);
                    $hasSetArrayArgument = true;
                } else {
                    $command->setArgumentValue($argument->getName(), array_shift($argumentValues));
                }
            }
        }
    }