public function getSynopsis(bool $short = false): array
    {
        $elements = $args = $opts = [];

        if ($short && $this->options) {
            $elements[] = '[options]';
        } elseif (!$short) {
            foreach ($this->options as $name => $option) {
                $value = '';

                if ($this->optionIsAcceptValue($option['mode'])) {
                    $value = \sprintf(
                        ' %s%s%s',
                        $option['optional'] ? '[' : '',
                        \strtoupper($name),
                        $option['optional'] ? ']' : ''
                    );
                }

                $shortcut = $option['shortcut'] ? \sprintf('-%s, ', $option['shortcut']) : '    ';
                $elements[] = \sprintf('[%s--%s%s]', $shortcut, $name, $value);

                $key = "{$shortcut}--{$name}";
                $opts[$key] = ($option['required'] ? '<red>*</red>' : '') . $option['description'];
            }
        }

        if ($this->arguments && \count($elements)) {
            $elements[] = '[--]';
        }

        foreach ($this->arguments as $name => $argument) {
            $des = $argument['required'] ? '<red>*</red>' . $argument['description'] : $argument['description'];

            $element = '<' . $name . '>';
            if (!$argument['required']) {
                $element = '[' . $element . ']';
            } elseif ($argument['isArray']) {
                $element = $element . ' (' . $element . ')';
            }

            if ($argument['isArray']) {
                $element .= '...';
            }

            $elements[] = $element;
            $args[$name] = $des;
        }

        return [
            $this->description,
            'usage:'          => \implode(' ', $elements),
            'options:'        => $opts,
            'arguments:'      => $args,
            'example:'        => $this->example,
            'global options:' => '',
        ];
    }
public function getSynopsis(bool $short = false): array
    {
        $elements = $args = $opts = [];

        if ($short && $this->options) {
            $elements[] = '[options]';
        } elseif (!$short) {
            foreach ($this->options as $name => $option) {
                $value = '';

                if ($this->optionIsAcceptValue($option['mode'])) {
                    $value = \sprintf(
                        ' %s%s%s',
                        $option['optional'] ? '[' : '',
                        \strtoupper($name),
                        $option['optional'] ? ']' : ''
                    );
                }

                $shortcut = $option['shortcut'] ? \sprintf('-%s, ', $option['shortcut']) : '    ';
                $elements[] = \sprintf('[%s--%s%s]', $shortcut, $name, $value);

                $key = "{$shortcut}--{$name}";
                $opts[$key] = ($option['required'] ? '<red>*</red>' : '') . $option['description'];
            }
        }

        if ($this->arguments && \count($elements)) {
            $elements[] = '[--]';
        }

        foreach ($this->arguments as $name => $argument) {
            $des = $argument['required'] ? '<red>*</red>' . $argument['description'] : $argument['description'];

            $element = '<' . $name . '>';
            if (!$argument['required']) {
                $element = '[' . $element . ']';
            } elseif ($argument['isArray']) {
                $element = $element . ' (' . $element . ')';
            }

            if ($argument['isArray']) {
                $element .= '...';
            }

            $elements[] = $element;
            $args[$name] = $des;
        }

        return [
            $this->description,
            'usage:'          => \implode(' ', $elements),
            'options:'        => $opts,
            'arguments:'      => $args,
            'example:'        => $this->example,
            'global options:' => '',
        ];
    }
public function getSynopsis ( bool $ short = false ) : array { $ elements = $ args = $ opts = [ ] ; if ( $ short && $ this -> options ) { $ elements [ ] = '[options]' ; } elseif ( ! $ short ) { foreach ( $ this -> options as $ name => $ option ) { $ value = '' ; if ( $ this -> optionIsAcceptValue ( $ option [ 'mode' ] ) ) { $ value = \ sprintf ( ' %s%s%s' , $ option [ 'optional' ] ? '[' : '' , \ strtoupper ( $ name ) , $ option [ 'optional' ] ? ']' : '' ) ; } $ shortcut = $ option [ 'shortcut' ] ? \ sprintf ( '-%s, ' , $ option [ 'shortcut' ] ) : '    ' ; $ elements [ ] = \ sprintf ( '[%s--%s%s]' , $ shortcut , $ name , $ value ) ; $ key = "{$shortcut}--{$name}" ; $ opts [ $ key ] = ( $ option [ 'required' ] ? '<red>*</red>' : '' ) . $ option [ 'description' ] ; } } if ( $ this -> arguments && \ count ( $ elements ) ) { $ elements [ ] = '[--]' ; } foreach ( $ this -> arguments as $ name => $ argument ) { $ des = $ argument [ 'required' ] ? '<red>*</red>' . $ argument [ 'description' ] : $ argument [ 'description' ] ; $ element = '<' . $ name . '>' ; if ( ! $ argument [ 'required' ] ) { $ element = '[' . $ element . ']' ; } elseif ( $ argument [ 'isArray' ] ) { $ element = $ element . ' (' . $ element . ')' ; } if ( $ argument [ 'isArray' ] ) { $ element .= '...' ; } $ elements [ ] = $ element ; $ args [ $ name ] = $ des ; } return [ $ this -> description , 'usage:' => \ implode ( ' ' , $ elements ) , 'options:' => $ opts , 'arguments:' => $ args , 'example:' => $ this -> example , 'global options:' => '' , ] ; }
Gets the synopsis.
@param bool $short 简化版显示
@return array
Gets the synopsis .