Parse the command.

@param Node   $node
@param string $command

@return array
190046
public function parse($node, $command)
    {
        if ($node->command() === '-') {
            $topic   = synapse()->memory->shortTerm()->get('topic') ?: 'random';
            $key     = synapse()->memory->shortTerm()->get('trigger');
            $trigger = synapse()->brain->topic($topic)->triggers()->get($key);

            $trigger['responses'][] = $node->value();

            synapse()->brain->topic($topic)->triggers()->put($key, $trigger);
        }
    }
982015
function parseCommandArgs() {
        if($this->command === null) {
            throw new \LogicException('This message has no command');
        }
        
        switch($this->command->argsType) {
            case 'single':
                $args = $this->argString;
                return \preg_replace(($this->command->argsSingleQuotes ? '/^("|\')(.*)\1$/u' : '/^(")(.*)"$/u'), '$2', $args);
            case 'multiple':
                return self::parseArgs($this->argString, $this->command->argsCount, $this->command->argsSingleQuotes);
            default:
                throw new \RangeException('Unknown argsType "'.$this->command->argsType.'".');
        }
    }
881080
public function transform(Command $command)
    {
        $block = $this->block->reflector(new \ReflectionClass($command));
        $lines = [];

        foreach ($block->getLines() as $line)
        {
            $lines[] = $line->stripTag();
        }

        list($name, $description, $signature) = $lines;

        $command->setName($name);
        $command->setDescription($description);
        $command->setDefinition($this->getDefinition($signature));
    }
1256785
private Command parse() throws ParseException {
        command();
        while (!is(Token.WHERE, Token.RETURN, Token.EOL)) { 
            param();
        }
        if (token == Token.WHERE) {
            where();
        }
        if (token == Token.RETURN) {
            returns();
        }
        expect(Token.EOL);
        return cmd;
    }
990094
def command_children(self, command):
        
        if not len(self.nodes):
            return

        commands = []
        for c in self.nodes:
            commands.append('[con_id="{}"] {};'.format(c.id, command))

        self._conn.command(' '.join(commands))
515085
private function parserCmdAndDesc(): array
    {
        $commands = [];
        $collector = CommandCollector::getCollector();

        /* @var \Swoft\Console\Router\HandlerMapping $route */
        $route = App::getBean('commandRoute');

        foreach ($collector as $className => $command) {
            if (!$command['enabled']) {
                continue;
            }

            $rc = new \ReflectionClass($className);
            $docComment = $rc->getDocComment();
            $docAry = DocBlockHelper::getTags($docComment);

            $prefix = $command['name'];
            $prefix = $route->getPrefix($prefix, $className);
            $commands[$prefix] = StringHelper::ucfirst($docAry['Description']);
        }

        // sort commands
        ksort($commands);

        return $commands;
    }
620945
public function getCallbacks($command)
    {
        $result = array();
        $command = strtolower($command);

        if (isset($this->_callbacks[$command])) {
            $result = $this->_callbacks[$command];
        }

        return $result;
    }
1262197
public function add(\Strukt\Console\Command $command){

		$class = get_class($command);
		$docBlockParser = new \Strukt\Console\DocBlockParser($class);
		$docList = $docBlockParser->parse();

		$cmdAlias = $docList["command"]["alias"];
		$this->commands[$cmdAlias]["object"] = $command;
		$this->commands[$cmdAlias]["docparser"] = $docBlockParser;
		$this->commands[$cmdAlias]["doclist"] = $docList;

		if($this->padlen == 0 || strlen($docList["command"]["alias"]) > $this->padlen)
			$this->padlen = strlen($docList["command"]["alias"]);
	}
324157
protected function aliasesFor(Command $command): array
    {
        $aliases = [$name = $command->name()];

        foreach ($this->aliases as $alias => $command) {
            if (\in_array($name, [$alias, $command])) {
                $aliases[] = $alias;
                $aliases[] = $command;
            }
        }

        return $aliases;
    }
112796
public function parse($command, array $arguments = array(), $output)
    {
        switch ($command) {
            case "status":
                return $this->parseStatusOutput($output);
                break;
            case "list":
                return $this->parseListOutput($output, $arguments);
                break;
            case "log":
                return $this->parseLogOutput($output, $arguments);
                break;
            case "diff":
                return $this->parseDiffOutput($output, $arguments);
                break;
        }

        return $output;
    }
41502
public function parse()
    {
        $this->rules = [];
        $parts = explode('|', $this->command);

        foreach ($parts as $part) {
            $segments = explode(':', $part);

            $this->rules[] = array(
                'name' => $segments[0],
                'args' => isset($segments[1]) ? explode(',', $segments[1]) : array()
            );
        }

        return $this->rules;
    }
14766
public function execute(string $command) : array
    {
        $this->result = [];
        $process = new Process(
            $this->propelCommand . ' ' . $command . ' --config-dir=' . $this->configDir,
            $this->rootDirectory
        );

        $process->run([$this, 'handle']);

        return $this->result;
    }
769013
public static function parseAndRunCommand($command)
    {
        try {
            list($class, $method, $args) = TaskManager::parseCommand($command);
            if (!class_exists($class)) {
                TaskLoader::loadController($class);
            }

            $obj = new $class();
            if (!method_exists($obj, $method)) {
                throw new TaskManagerException('method ' . $method . ' not found in class ' . $class);
            }

            return call_user_func_array(array($obj, $method), $args);
        } catch (\Exception $e) {
            echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL;
            return false;
        }
    }
82610
public function run(string $file, Node $node): array
    {
        if ($node->flags !== \ast\flags\BINARY_BOOL_OR) {
            return [];
        }

        if ($this->isArrayAndInstanceOfCountable($node->children['left'], $node->children['right'])
             || $this->isArrayAndInstanceOfCountable($node->children['right'], $node->children['left'])) {
            return [new Hint(
                self::HINT_TYPE,
                self::HINT_MESSAGE,
                $file,
                $node->lineno,
                self::HINT_LINK
            )];
        }

        return [];
    }
997866
public static function getCommandDescription(WebDriver_Command $command)
    {
        $commandDescriptionList = [
            "Command: {$command->getCommandName()}",
            "Method: {$command->getMethod()}",
            "URL: {$command->getUrl()}"
        ];
        $paramList = $command->getParameters();
        if (!empty($paramList)) {
            $commandDescriptionList = array_merge(
                $commandDescriptionList,
                ["Parameters:", var_export($paramList, true)]
            );
        }
        return implode("\n", $commandDescriptionList);
    }
1335705
public function parse($source, $filename = '', $env = null)
    {
        if (!$env) {
            $env = $this->options;
        }

        if (!class_exists('H2o_Parser', false)) {
            require H2O_ROOT.'h2o/parser.php';
        }

        $parser = new H2o_Parser($source, $filename, $this, $env);
        $nodelist = $parser->parse();

        return $nodelist;
    }
682205
protected function parseValues(\SimpleXMLElement $node)
    {
        $values = [];

        foreach ($node->value as $item) {
            if ($item->count() > 0) {
                $value = $this->parseValues($item);
            } else {
                $value = trim($item);
            }

            if (isset($item['key'])) {
                $values[(string) $item['key']] = $value;
            } else {
                $values[] = $value;
            }
        }

        return $values;
    }