protected function parseArguments(array $argv)
    {
        $positional = [];
        $options = [];

        for ($ii = 0; $ii < count($argv); ++$ii) {
            // Skipping the first argument.
            if (0 === $ii) {
                continue;
            }

            $v = $argv[$ii];

            if ('--' === substr($v, 0, 2)) {
                // This is a long-form option.
                $optionName = substr($v, 2);
                $optionValue = true;
                if (strpos($optionName, '=')) {
                    list($optionName, $optionValue) = explode('=', $optionName);
                }
                $options[$optionName] = $optionValue;
            } elseif ('-' === substr($v, 0, 1) && strlen($v) > 1) {
                // This is a short-form option.
                foreach (str_split(substr($v, 1)) as $option) {
                    $options[$option] = true;
                }
            } else {
                $positional[] = $v;
            }
        }

        return [$options, $positional];
    }