framework/console/controllers/HelpController.php
protected function getSubCommandHelp($controller, $actionID)
    {
        $action = $controller->createAction($actionID);
        if ($action === null) {
            $name = $this->ansiFormat(rtrim($controller->getUniqueId() . '/' . $actionID, '/'), Console::FG_YELLOW);
            throw new Exception("No help for unknown sub-command \"$name\".");
        }

        $description = $controller->getActionHelp($action);
        if ($description !== '') {
            $this->stdout("\nDESCRIPTION\n", Console::BOLD);
            $this->stdout("\n$description\n\n");
        }

        $this->stdout("\nUSAGE\n\n", Console::BOLD);
        $scriptName = $this->getScriptName();
        if ($action->id === $controller->defaultAction) {
            $this->stdout($scriptName . ' ' . $this->ansiFormat($controller->getUniqueId(), Console::FG_YELLOW));
        } else {
            $this->stdout($scriptName . ' ' . $this->ansiFormat($action->getUniqueId(), Console::FG_YELLOW));
        }

        $args = $controller->getActionArgsHelp($action);
        foreach ($args as $name => $arg) {
            if ($arg['required']) {
                $this->stdout(' <' . $name . '>', Console::FG_CYAN);
            } else {
                $this->stdout(' [' . $name . ']', Console::FG_CYAN);
            }
        }

        $options = $controller->getActionOptionsHelp($action);
        $options[\yii\console\Application::OPTION_APPCONFIG] = [
            'type' => 'string',
            'default' => null,
            'comment' => "custom application configuration file path.\nIf not set, default application configuration is used.",
        ];
        ksort($options);

        if (!empty($options)) {
            $this->stdout(' [...options...]', Console::FG_RED);
        }
        $this->stdout("\n\n");

        if (!empty($args)) {
            foreach ($args as $name => $arg) {
                $this->stdout($this->formatOptionHelp(
                        '- ' . $this->ansiFormat($name, Console::FG_CYAN),
                        $arg['required'],
                        $arg['type'],
                        $arg['default'],
                        $arg['comment']) . "\n\n");
            }
        }

        if (!empty($options)) {
            $this->stdout("\nOPTIONS\n\n", Console::BOLD);
            foreach ($options as $name => $option) {
                $this->stdout($this->formatOptionHelp(
                        $this->ansiFormat('--' . $name . $this->formatOptionAliases($controller, $name),
                            Console::FG_RED, empty($option['required']) ? Console::FG_RED : Console::BOLD),
                        !empty($option['required']),
                        $option['type'],
                        $option['default'],
                        $option['comment']) . "\n\n");
            }
        }
    }
protected function getSubCommandHelp($controller, $actionID)
    {
        $action = $controller->createAction($actionID);
        if ($action === null) {
            $name = $this->ansiFormat(rtrim($controller->getUniqueId() . '/' . $actionID, '/'), Console::FG_YELLOW);
            throw new Exception("No help for unknown sub-command \"$name\".");
        }

        $description = $controller->getActionHelp($action);
        if ($description !== '') {
            $this->stdout("\nDESCRIPTION\n", Console::BOLD);
            $this->stdout("\n$description\n\n");
        }

        $this->stdout("\nUSAGE\n\n", Console::BOLD);
        $scriptName = $this->getScriptName();
        if ($action->id === $controller->defaultAction) {
            $this->stdout($scriptName . ' ' . $this->ansiFormat($controller->getUniqueId(), Console::FG_YELLOW));
        } else {
            $this->stdout($scriptName . ' ' . $this->ansiFormat($action->getUniqueId(), Console::FG_YELLOW));
        }

        $args = $controller->getActionArgsHelp($action);
        foreach ($args as $name => $arg) {
            if ($arg['required']) {
                $this->stdout(' <' . $name . '>', Console::FG_CYAN);
            } else {
                $this->stdout(' [' . $name . ']', Console::FG_CYAN);
            }
        }

        $options = $controller->getActionOptionsHelp($action);
        $options[\yii\console\Application::OPTION_APPCONFIG] = [
            'type' => 'string',
            'default' => null,
            'comment' => "custom application configuration file path.\nIf not set, default application configuration is used.",
        ];
        ksort($options);

        if (!empty($options)) {
            $this->stdout(' [...options...]', Console::FG_RED);
        }
        $this->stdout("\n\n");

        if (!empty($args)) {
            foreach ($args as $name => $arg) {
                $this->stdout($this->formatOptionHelp(
                        '- ' . $this->ansiFormat($name, Console::FG_CYAN),
                        $arg['required'],
                        $arg['type'],
                        $arg['default'],
                        $arg['comment']) . "\n\n");
            }
        }

        if (!empty($options)) {
            $this->stdout("\nOPTIONS\n\n", Console::BOLD);
            foreach ($options as $name => $option) {
                $this->stdout($this->formatOptionHelp(
                        $this->ansiFormat('--' . $name . $this->formatOptionAliases($controller, $name),
                            Console::FG_RED, empty($option['required']) ? Console::FG_RED : Console::BOLD),
                        !empty($option['required']),
                        $option['type'],
                        $option['default'],
                        $option['comment']) . "\n\n");
            }
        }
    }
protected function getSubCommandHelp ( $ controller , $ actionID ) { $ action = $ controller -> createAction ( $ actionID ) ; if ( $ action === null ) { $ name = $ this -> ansiFormat ( rtrim ( $ controller -> getUniqueId ( ) . '/' . $ actionID , '/' ) , Console :: FG_YELLOW ) ; throw new Exception ( "No help for unknown sub-command \"$name\"." ) ; } $ description = $ controller -> getActionHelp ( $ action ) ; if ( $ description !== '' ) { $ this -> stdout ( "\nDESCRIPTION\n" , Console :: BOLD ) ; $ this -> stdout ( "\n$description\n\n" ) ; } $ this -> stdout ( "\nUSAGE\n\n" , Console :: BOLD ) ; $ scriptName = $ this -> getScriptName ( ) ; if ( $ action -> id === $ controller -> defaultAction ) { $ this -> stdout ( $ scriptName . ' ' . $ this -> ansiFormat ( $ controller -> getUniqueId ( ) , Console :: FG_YELLOW ) ) ; } else { $ this -> stdout ( $ scriptName . ' ' . $ this -> ansiFormat ( $ action -> getUniqueId ( ) , Console :: FG_YELLOW ) ) ; } $ args = $ controller -> getActionArgsHelp ( $ action ) ; foreach ( $ args as $ name => $ arg ) { if ( $ arg [ 'required' ] ) { $ this -> stdout ( ' <' . $ name . '>' , Console :: FG_CYAN ) ; } else { $ this -> stdout ( ' [' . $ name . ']' , Console :: FG_CYAN ) ; } } $ options = $ controller -> getActionOptionsHelp ( $ action ) ; $ options [ \ yii \ console \ Application :: OPTION_APPCONFIG ] = [ 'type' => 'string' , 'default' => null , 'comment' => "custom application configuration file path.\nIf not set, default application configuration is used." , ] ; ksort ( $ options ) ; if ( ! empty ( $ options ) ) { $ this -> stdout ( ' [...options...]' , Console :: FG_RED ) ; } $ this -> stdout ( "\n\n" ) ; if ( ! empty ( $ args ) ) { foreach ( $ args as $ name => $ arg ) { $ this -> stdout ( $ this -> formatOptionHelp ( '- ' . $ this -> ansiFormat ( $ name , Console :: FG_CYAN ) , $ arg [ 'required' ] , $ arg [ 'type' ] , $ arg [ 'default' ] , $ arg [ 'comment' ] ) . "\n\n" ) ; } } if ( ! empty ( $ options ) ) { $ this -> stdout ( "\nOPTIONS\n\n" , Console :: BOLD ) ; foreach ( $ options as $ name => $ option ) { $ this -> stdout ( $ this -> formatOptionHelp ( $ this -> ansiFormat ( '--' . $ name . $ this -> formatOptionAliases ( $ controller , $ name ) , Console :: FG_RED , empty ( $ option [ 'required' ] ) ? Console :: FG_RED : Console :: BOLD ) , ! empty ( $ option [ 'required' ] ) , $ option [ 'type' ] , $ option [ 'default' ] , $ option [ 'comment' ] ) . "\n\n" ) ; } } }
Displays the detailed information of a command action.
@param Controller $controller the controller instance
@param string $actionID action ID
@throws Exception if the action does not exist
Displays the detailed information of a command action .