protected function runCommand(string $name, $handler, array $options)
    {
        if (\is_object($handler) && \method_exists($handler, '__invoke')) {
            if ($this->input->getSameOpt(['h', 'help'])) {
                $desc = $options['description'] ?? 'No command description message';

                return $this->output->write($desc);
            }

            $result = $handler($this->input, $this->output);
        } else {
            if (!\class_exists($handler)) {
                Helper::throwInvalidArgument("The console command class [$handler] not exists!");
            }

            /** @var Command $object */
            $object = new $handler($this->input, $this->output);

            if (!($object instanceof Command)) {
                Helper::throwInvalidArgument("The console command class [$handler] must instanceof the " . Command::class);
            }

            $object::setName($name);
            $object->setApp($this);
            $result = $object->run();
        }

        return $result;
    }
protected function runCommand(string $name, $handler, array $options)
    {
        if (\is_object($handler) && \method_exists($handler, '__invoke')) {
            if ($this->input->getSameOpt(['h', 'help'])) {
                $desc = $options['description'] ?? 'No command description message';

                return $this->output->write($desc);
            }

            $result = $handler($this->input, $this->output);
        } else {
            if (!\class_exists($handler)) {
                Helper::throwInvalidArgument("The console command class [$handler] not exists!");
            }

            /** @var Command $object */
            $object = new $handler($this->input, $this->output);

            if (!($object instanceof Command)) {
                Helper::throwInvalidArgument("The console command class [$handler] must instanceof the " . Command::class);
            }

            $object::setName($name);
            $object->setApp($this);
            $result = $object->run();
        }

        return $result;
    }
protected function runCommand ( string $ name , $ handler , array $ options ) { if ( \ is_object ( $ handler ) && \ method_exists ( $ handler , '__invoke' ) ) { if ( $ this -> input -> getSameOpt ( [ 'h' , 'help' ] ) ) { $ desc = $ options [ 'description' ] ?? 'No command description message' ; return $ this -> output -> write ( $ desc ) ; } $ result = $ handler ( $ this -> input , $ this -> output ) ; } else { if ( ! \ class_exists ( $ handler ) ) { Helper :: throwInvalidArgument ( "The console command class [$handler] not exists!" ) ; } /** @var Command $object */ $ object = new $ handler ( $ this -> input , $ this -> output ) ; if ( ! ( $ object instanceof Command ) ) { Helper :: throwInvalidArgument ( "The console command class [$handler] must instanceof the " . Command :: class ) ; } $ object :: setName ( $ name ) ; $ object -> setApp ( $ this ) ; $ result = $ object -> run ( ) ; } return $ result ; }
run a independent command
@param string          $name Command name
@param \Closure|string $handler Command class
@param array           $options
@return mixed
@throws \InvalidArgumentException
run a independent command