@param Command $command

@return self
344811
public static function notFound(Command $command)
    {
        $parts = explode('\\', get_class($command));

        return new self(sprintf('Not found handler for command "%s".', end($parts)));
    }
58230
protected function registerMakeJobCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Generators\Commands\JobMakeCommand($app);
        });
    }
562498
public function resolve($command)
    {
        $commandInstance = $this->di->get($command);

        return $this->add($commandInstance);
    }
1197968
public function run($command)
    {
        $this->command = escapeshellcmd($command);
        $this->process->setCommandLine($this->command);
        $this->process->run();
        $this->validateRun();

        return $this;
    }
1128473
protected function registerMakeRequestCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Generators\Commands\RequestMakeCommand($app);
        });
    }
81631
protected function doAction(Command $command)
    {
        if ($command->name() === '__default__') {
            return $this->notFound();
        }

        // Let the command collect more data (if missing or needs confirmation)
        $command->interact($this->io());

        if (!$command->action() && !\method_exists($command, 'execute')) {
            return;
        }

        $params = [];
        $values = $command->values();
        // We prioritize action to be in line with commander.js!
        $action = $command->action() ?? [$command, 'execute'];

        foreach ($this->getActionParameters($action) as $param) {
            $params[] = $values[$param->getName()] ?? null;
        }

        return $action(...$params);
    }
258226
protected function executeCmd($command)
    {
        $process = new $this->processClass($command);
        $process->run();

        if (false === $process->isSuccessful() && strlen($process->getErrorOutput()) > 0) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return $process->getOutput();
    }
584392
public function executeCommand(Command $command)
    {
        if ($command instanceof DsnDependent) {
            $command->setDsn($this->dsn);
        }

        $shellCmd = self::VTCTLD_EXECUTABLE . ' ' . $this->getServerString() . ' '
             . $command->getName() . ' ' . implode(' ', $command->getParams());

        exec($shellCmd, $output, $return);
        $output = implode("\n", $output);

        if ($return !== 0) {
            throw new Exception('Error running vtctld command - ' . $shellCmd . ', error: ' . $output);
        }

        $resultClass = $command->getResultClass();

        return new $resultClass($this->dsn, $output);
    }
696630
public function addCommand($command)
    {
        if (is_array($command)) {
            foreach ($command as $cmd) {
                $this->addCommand($cmd);
            }
        }

        if (is_string($command)) {
            $command = new Command($command);
            $this->commandsList[] = $command;
        }

        return $this;
    }
41300
public function add(BaseCommand $command)
    {
        if ($ret = parent::add($command)) {
            if ($ret instanceof ContextAware) {
                $ret->setContext($this->context);
            }

            if ($ret instanceof PresenterAware) {
                $ret->setPresenter($this->config->getPresenter());
            }

            if (isset($this->commandsMatcher)) {
                $this->commandsMatcher->setCommands($this->all());
            }
        }

        return $ret;
    }
517125
public function addCommand($command)
    {
        $command = $this->resolveCommandObject($command);

        /*
         * At this stage we definitely have a proper command to use.
         *
         * @var Command $command
         */
        $this->commands[$command->getName()] = $command;

        $aliases = $command->getAliases();

        if (empty($aliases)) {
            return $this;
        }

        foreach ($command->getAliases() as $alias) {
            if (isset($this->commands[$alias])) {
                throw new TelegramSDKException(sprintf(
                    '[Error] Alias [%s] conflicts with command name of "%s" try with another name or remove this alias from the list.',
                    $alias,
                    get_class($command)
                ));
            }

            if (isset($this->commandAliases[$alias])) {
                throw new TelegramSDKException(sprintf(
                    '[Error] Alias [%s] conflicts with another command\'s alias list: "%s", try with another name or remove this alias from the list.',
                    $alias,
                    get_class($command)
                ));
            }

            $this->commandAliases[$alias] = $command;
        }

        return $this;


    }
221583
public function add(CommandInterface $command)
    {
        $this->sequence[] = $command;

        if ($this->hasConfig()) {
            $command->setConfig($this->getConfig());
        }

        return $this;
    }
1038700
protected function registerTailCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Commands\TailCommand($app);
        });
    }
836621
protected function registerMakeControllerCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Generators\Commands\ControllerMakeCommand($app);
        });
    }
184130
public function handle(Command $command)
    {
        $handler = $this->container->make($this->handlerName);

        return $handler->handle($command);
    }
730360
function unregisterCommand(\CharlotteDunois\Livia\Commands\Command $command) {
        $group = $this->resolveGroup($command->groupID);
        $group->commands->delete($command->name);
        $this->commands->delete($command->name);
        
        $this->client->emit('debug', 'Unregistered command '.$command->groupID.':'.$command->name);
        $this->client->emit('commandUnregister', $command, $this);
        
        return $this;
    }
97408
public static function create(Command $command): CommandMessage
    {
        $timestamp = DateTime::now();
        $id = MessageId::generate();
        $metaData = MetaData::create();

        return new static($id, $timestamp, $command, $metaData);
    }