Initiate an entry being added to the history.

@param CommandInterface $cmd Command be executed.
@param RequestInterface $req Request being sent.

@return string Returns the ticket used to finish the entry.
165367
public function start(CommandInterface $cmd, RequestInterface $req)
    {
        $ticket = uniqid();
        $this->entries[$ticket] = [
            'command'   => $cmd,
            'request'   => $req,
            'result'    => null,
            'exception' => null,
        ];

        return $ticket;
    }
851020
public static SmtpRequest help(String cmd) {
        return cmd == null ? HELP_NO_ARG : new DefaultSmtpRequest(SmtpCommand.HELP, cmd);
    }
475278
final public static function exec(string $cmd, array $args=[]) {
		foreach ($args as $key => $val)
			$args[$key] = escapeshellarg($val);
		$cmd = vsprintf($cmd, $args);
		exec($cmd, $output, $retcode);
		if ($retcode !== 0)
			return false;
		return $output;
	}
1250692
public static function getCommandPath($cmd)
    {
        $os_cmd = exec('which '.$cmd);
        if (empty($os_cmd)) {
            throw new CommandNotFoundException($cmd);
        }
        return $os_cmd;
    }
690871
public function commandFlags(CommandInterface $cmd, $cmdSignature)
    {
        $args = [];
        $specs = $cmd->getOptionCollection();
        /*
        '(- 1 *)--version[display version and copyright information]' \
        '(- 1 *)--help[print a short help statement]' \
        */
        foreach ($specs->options as $opt) {
            $args[] = $this->optionFlagItem($opt, $cmdSignature);
        }

        return empty($args) ? null : $args;
    }
1017863
function cmd_RMD($fd, $cmd)
    {
        $user = $this->getUser($fd);
        $dir = $this->fillDirName($user, $cmd[1]);
        $this->debug("RMDIR: $dir");
        if (is_dir(dirname($dir)) and is_dir($dir))
        {
            if (count(glob($dir . "/*")))
            {
                $this->send($fd, "550 Can't remove directory: Directory not empty");
            }
            elseif (rmdir($dir))
            {
                $this->send($fd, "250 The directory was successfully removed");
            }
            else
            {
                $this->send($fd, "550 Can't remove directory: Operation not permitted");
            }
        }
        elseif (is_dir(dirname($dir)) and file_exists($dir))
        {
            $this->send($fd, "550 Can't remove directory: Not a directory");
        }
        else
        {
            $this->send($fd, "550 Can't create directory: No such file or directory");
        }
    }
1195783
public function runCommand($cmd, $timeout = 120)
    {
        switch ($this->getStage()) {
            case self::ON_DEPLOY:
            case self::ON_RELEASE:
            case self::POST_RELEASE:
                return $this->runRemoteCommand($cmd, true, $timeout);
            default:
                return $this->runLocalCommand($cmd, $timeout);
        }
    }
461596
public function visit(
        CommandInterface $command,
        RequestInterface $request,
        Parameter $param
    ) {
        $this->jsonData[$param->getWireName()] = $this->prepareValue(
            $command[$param->getName()],
            $param
        );

        return $request->withBody(Psr7\stream_for(\GuzzleHttp\json_encode($this->jsonData)));
    }
246637
protected function listCommands(CommandEvent $event, EventQueueInterface $queue)
    {
        $targets = $event->getTargets();
        $target = reset($targets);
        $nick = $event->getNick();

        if ($target === $event->getConnection()->getNickname()) {
            $target = $nick;
            $address = '';
        } else {
            $address = $nick . ': ';
        }

        $method = 'irc' . $event->getCommand();
        $message = $address . $this->listText . implode(' ', $this->commands);
        $queue->$method($target, $message);
    }
857560
protected function getStartCommandMessage(CommandInterface $command, $store = null)
    {
        $commandInfo = sprintf('Command <fg=green>%s</>', $command->getName());
        $storeInfo = ($store) ?  sprintf(' for <info>%s</info> store', $store) : '';
        $executedInfo = sprintf(' <fg=yellow>[%s]</>', $command->getExecutable());

        return $commandInfo . $storeInfo . $executedInfo;
    }
1158737
private function _cmd($cmd) {
        $path = str_replace("\\","/\\", $this->_path);
        $cmd = "cd ".$path." && ".$cmd;
        $last_line = system($cmd, $retval);
        $this->_writeLog( $retval );
        return $last_line;
    }
31637
public function add(Horde_Imap_Client_Interaction_Command $cmd,
                        $top = false)
    {
        if ($top) {
            // This won't re-index keys, which may be numerical.
            $this->_commands = array($cmd->tag => $cmd) + $this->_commands;
        } else {
            $this->_commands[$cmd->tag] = $cmd;
        }
        $this->_todo[$cmd->tag] = true;
    }
1248407
public function inform($cmd, $params = [])
    {
        switch ($cmd) {
          case 'label': // module's short name for menu
            if (!empty($this->params['label'])) {
                $label = $this->params['label'];
                // try to translate label
                $tcCat = TranslationsBuilder::getBaseTransCategory($this);
                $tc = "{$tcCat}/module";
                if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) {
                    $label = Yii::t($tc, $this->params['label']);
                }
                return $label;
            } else {
                //return false;
                try {
                    $ms = Yii::$app->i18n->getMessageSource(static::$tc);
                } catch(InvalidConfigException $ex) {
                    $ms = false;
                }
                return ($ms ? Yii::t(static::$tc, 'Module') : 'Module') . ' ' . $this->uniqueId;
            }
            break;
          case 'sitetree-params-action': // return action in route format
            //if (empty($params['module_full_id'])) return false;
            if (!empty($this->params['sitetree-params-action'])) return $this->params['sitetree-params-action'];
            break;
//todo
        }
        return null;
    }
939658
protected function prepareRequest(
        CommandTransaction $trans,
        RequestInterface $request
    ) {
        $visitedLocations = [];
        $context = ['client' => $trans->client, 'command' => $trans->command];
        $operation = $this->description->getOperation($trans->command->getName());

        // Visit each actual parameter
        foreach ($operation->getParams() as $name => $param) {
            /* @var Parameter $param */
            $location = $param->getLocation();
            // Skip parameters that have not been set or are URI location
            if ($location == 'uri' || !$trans->command->hasParam($name)) {
                continue;
            }
            if (!isset($this->requestLocations[$location])) {
                throw new \RuntimeException("No location registered for $name");
            }
            $visitedLocations[$location] = true;
            $this->requestLocations[$location]->visit(
                $trans->command,
                $request,
                $param,
                $context
            );
        }

        // Ensure that the after() method is invoked for additionalParameters
        if ($additional = $operation->getAdditionalParameters()) {
            $visitedLocations[$additional->getLocation()] = true;
        }

        // Call the after() method for each visited location
        foreach (array_keys($visitedLocations) as $location) {
            $this->requestLocations[$location]->after(
                $trans->command,
                $request,
                $operation,
                $context
            );
        }
    }
143811
public function cmd($cmd)
    {
        $cmd = ltrim($cmd);
        if (substr($cmd, 0, 1) === '@') {
            return $this->resolve(array_merge(array('tasks'), explode('.', substr($cmd, 1))));
        } else {
            $this->exec($cmd);
            return null;
        }
    }
350520
public function preImport(CommandData $commandData) {
    $userid = $commandData->input()->getOption('userid');
    if ($userid) {
      $account = User::load($userid);
      $accountSwitcher = \Drupal::service('account_switcher');
      $userSession = new UserSession([
        'uid'   => $account->id(),
        'name'  => $account->getUsername(),
        'roles' => $account->getRoles(),
      ]);
      $accountSwitcher->switchTo($userSession);
      $this->logger()->notice(
          dt(
              'Now acting as user ID @id',
              ['@id' => \Drupal::currentUser()->id()]
            )
      );
    }
  }
912881
public function command($commandId)
    {
        $this->getLogger()->info('Sending predefined Command to display Group ID ' . $this->displayGroupId);
        $this->doPost('/displaygroup/' . $this->displayGroupId . '/action/command', [
            'commandId' => $commandId,
        ]);

        return $this;
    }