addShortOption example

/** * Parses a short option. */
    private function parseShortOption(string $token): void
    {
        $name = substr($token, 1);

        if (\strlen($name) > 1) {
            if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
                // an option with a value (with no space)                 $this->addShortOption($name[0]substr($name, 1));
            } else {
                $this->parseShortOptionSet($name);
            }
        } else {
            $this->addShortOption($name, null);
        }
    }

    /** * Parses a short option set. * * @throws RuntimeException When option given doesn't exist */

    protected function parse()
    {
        foreach ($this->parameters as $key => $value) {
            if ('--' === $key) {
                return;
            }
            if (str_starts_with($key, '--')) {
                $this->addLongOption(substr($key, 2)$value);
            } elseif (str_starts_with($key, '-')) {
                $this->addShortOption(substr($key, 1)$value);
            } else {
                $this->addArgument($key$value);
            }
        }
    }

    /** * Adds a short option value. * * @throws InvalidOptionException When option given doesn't exist */
    

    protected function parse()
    {
        foreach ($this->parameters as $key => $value) {
            if ('--' === $key) {
                return;
            }
            if (str_starts_with($key, '--')) {
                $this->addLongOption(substr($key, 2)$value);
            } elseif (str_starts_with($key, '-')) {
                $this->addShortOption(substr($key, 1)$value);
            } else {
                $this->addArgument($key$value);
            }
        }
    }

    /** * Adds a short option value. * * @throws InvalidOptionException When option given doesn't exist */
    
/** * Parses a short option. */
    private function parseShortOption(string $token): void
    {
        $name = substr($token, 1);

        if (\strlen($name) > 1) {
            if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
                // an option with a value (with no space)                 $this->addShortOption($name[0]substr($name, 1));
            } else {
                $this->parseShortOptionSet($name);
            }
        } else {
            $this->addShortOption($name, null);
        }
    }

    /** * Parses a short option set. * * @throws RuntimeException When option given doesn't exist */
Home | Imprint | This part of the site doesn't use cookies.