final public function showCommandList(): void
    {
        $this->beforeShowCommandList();

        $ref   = new \ReflectionClass($this);
        $sName = \lcfirst(self::getName() ?: $ref->getShortName());

        if (!($classDes = self::getDescription())) {
            $classDes = PhpDoc::description($ref->getDocComment()) ?: 'No description for the command group';
        }

        $commands     = [];
        $showDisabled = (bool)$this->getOpt('show-disabled', false);
        $defaultDes   = 'No description message';

        foreach ($this->getAllCommandMethods($ref) as $cmd => $m) {
            if (!$cmd) {
                continue;
            }

            $desc = PhpDoc::firstLine($m->getDocComment()) ?: $defaultDes;

            // is a annotation tag
            if (\strpos($desc, '@') === 0) {
                $desc = $defaultDes;
            }

            if ($this->isDisabled($cmd)) {
                if (!$showDisabled) {
                    continue;
                }

                $desc .= '[<red>DISABLED</red>]';
            }

            $aliases = $this->getCommandAliases($cmd);
            $desc    .= $aliases ? ColorTag::wrap(' [alias: ' . \implode(',', $aliases) . ']', 'info') : '';

            $commands[$cmd] = $desc;
        }

        // sort commands
        \ksort($commands);

        // move 'help' to last.
        if ($helpCmd = $commands['help'] ?? null) {
            unset($commands['help']);
            $commands['help'] = $helpCmd;
        }

        $script = $this->getScriptName();

        if ($this->executionAlone) {
            $name  = $sName . ' ';
            $usage = "$script <info>{command}</info> [--options ...] [arguments ...]";
        } else {
            $name  = $sName . $this->delimiter;
            $usage = "$script {$name}<info>{command}</info> [--options ...] [arguments ...]";
        }

        $globalOptions = \array_merge(Application::getGlobalOptions(), static::$globalOptions);

        $this->output->startBuffer();
        $this->output->write(\ucfirst($classDes) . \PHP_EOL);
        $this->output->mList([
            'Usage:'              => $usage,
            //'Group Name:' => "<info>$sName</info>",
            'Global Options:'     => FormatUtil::alignOptions($globalOptions),
            'Available Commands:' => $commands,
        ], [
            'sepChar' => '  ',
        ]);

        $this->write(\sprintf(
            'More information about a command, please use: <cyan>%s %s{command} -h</cyan>',
            $script,
            $this->executionAlone ? '' : $name
        ));
        $this->output->flush();
    }
final public function showCommandList(): void
    {
        $this->beforeShowCommandList();

        $ref   = new \ReflectionClass($this);
        $sName = \lcfirst(self::getName() ?: $ref->getShortName());

        if (!($classDes = self::getDescription())) {
            $classDes = PhpDoc::description($ref->getDocComment()) ?: 'No description for the command group';
        }

        $commands     = [];
        $showDisabled = (bool)$this->getOpt('show-disabled', false);
        $defaultDes   = 'No description message';

        foreach ($this->getAllCommandMethods($ref) as $cmd => $m) {
            if (!$cmd) {
                continue;
            }

            $desc = PhpDoc::firstLine($m->getDocComment()) ?: $defaultDes;

            // is a annotation tag
            if (\strpos($desc, '@') === 0) {
                $desc = $defaultDes;
            }

            if ($this->isDisabled($cmd)) {
                if (!$showDisabled) {
                    continue;
                }

                $desc .= '[<red>DISABLED</red>]';
            }

            $aliases = $this->getCommandAliases($cmd);
            $desc    .= $aliases ? ColorTag::wrap(' [alias: ' . \implode(',', $aliases) . ']', 'info') : '';

            $commands[$cmd] = $desc;
        }

        // sort commands
        \ksort($commands);

        // move 'help' to last.
        if ($helpCmd = $commands['help'] ?? null) {
            unset($commands['help']);
            $commands['help'] = $helpCmd;
        }

        $script = $this->getScriptName();

        if ($this->executionAlone) {
            $name  = $sName . ' ';
            $usage = "$script <info>{command}</info> [--options ...] [arguments ...]";
        } else {
            $name  = $sName . $this->delimiter;
            $usage = "$script {$name}<info>{command}</info> [--options ...] [arguments ...]";
        }

        $globalOptions = \array_merge(Application::getGlobalOptions(), static::$globalOptions);

        $this->output->startBuffer();
        $this->output->write(\ucfirst($classDes) . \PHP_EOL);
        $this->output->mList([
            'Usage:'              => $usage,
            //'Group Name:' => "<info>$sName</info>",
            'Global Options:'     => FormatUtil::alignOptions($globalOptions),
            'Available Commands:' => $commands,
        ], [
            'sepChar' => '  ',
        ]);

        $this->write(\sprintf(
            'More information about a command, please use: <cyan>%s %s{command} -h</cyan>',
            $script,
            $this->executionAlone ? '' : $name
        ));
        $this->output->flush();
    }
final public function showCommandList ( ) : void { $ this -> beforeShowCommandList ( ) ; $ ref = new \ ReflectionClass ( $ this ) ; $ sName = \ lcfirst ( self :: getName ( ) ? : $ ref -> getShortName ( ) ) ; if ( ! ( $ classDes = self :: getDescription ( ) ) ) { $ classDes = PhpDoc :: description ( $ ref -> getDocComment ( ) ) ? : 'No description for the command group' ; } $ commands = [ ] ; $ showDisabled = ( bool ) $ this -> getOpt ( 'show-disabled' , false ) ; $ defaultDes = 'No description message' ; foreach ( $ this -> getAllCommandMethods ( $ ref ) as $ cmd => $ m ) { if ( ! $ cmd ) { continue ; } $ desc = PhpDoc :: firstLine ( $ m -> getDocComment ( ) ) ? : $ defaultDes ; // is a annotation tag if ( \ strpos ( $ desc , '@' ) === 0 ) { $ desc = $ defaultDes ; } if ( $ this -> isDisabled ( $ cmd ) ) { if ( ! $ showDisabled ) { continue ; } $ desc .= '[<red>DISABLED</red>]' ; } $ aliases = $ this -> getCommandAliases ( $ cmd ) ; $ desc .= $ aliases ? ColorTag :: wrap ( ' [alias: ' . \ implode ( ',' , $ aliases ) . ']' , 'info' ) : '' ; $ commands [ $ cmd ] = $ desc ; } // sort commands \ ksort ( $ commands ) ; // move 'help' to last. if ( $ helpCmd = $ commands [ 'help' ] ?? null ) { unset ( $ commands [ 'help' ] ) ; $ commands [ 'help' ] = $ helpCmd ; } $ script = $ this -> getScriptName ( ) ; if ( $ this -> executionAlone ) { $ name = $ sName . ' ' ; $ usage = "$script <info>{command}</info> [--options ...] [arguments ...]" ; } else { $ name = $ sName . $ this -> delimiter ; $ usage = "$script {$name}<info>{command}</info> [--options ...] [arguments ...]" ; } $ globalOptions = \ array_merge ( Application :: getGlobalOptions ( ) , static :: $ globalOptions ) ; $ this -> output -> startBuffer ( ) ; $ this -> output -> write ( \ ucfirst ( $ classDes ) . \ PHP_EOL ) ; $ this -> output -> mList ( [ 'Usage:' => $ usage , //'Group Name:' => "<info>$sName</info>", 'Global Options:' => FormatUtil :: alignOptions ( $ globalOptions ) , 'Available Commands:' => $ commands , ] , [ 'sepChar' => '  ' , ] ) ; $ this -> write ( \ sprintf ( 'More information about a command, please use: <cyan>%s %s{command} -h</cyan>' , $ script , $ this -> executionAlone ? '' : $ name ) ) ; $ this -> output -> flush ( ) ; }
Display all sub-commands list of the controller class
@throws \ReflectionException
Display all sub - commands list of the controller class