Process an array of commands.

@param string|array $commands

@return array
6055
public function processCommands($commands)
    {
        $separator = $this->environment->getSeparator();
        $shell = $this->config->getContextually('remote.shell');
        $shelled = $this->config->getContextually('remote.shelled');
        $sudo = $this->config->getContextually('remote.sudo');
        $sudoed = $this->config->getContextually('remote.sudoed');

        // Prepare paths replacer
        $pattern = sprintf('#\%s([\w\d\s])#', DS);
        $replacement = sprintf('\%s$1', $separator);

        // Cast commands to array
        if (!is_array($commands)) {
            $commands = [$commands];
        }

        // Flatten and process commands
        $commands = Arr::flatten($commands);
        foreach ($commands as &$command) {
            // Replace directory separators
            if (DS !== $separator) {
                $command = preg_replace($pattern, $replacement, $command);
            }

            // Let framework process commands
            if ($framework = $this->getFramework()) {
                $command = $framework->processCommand($command);
            }

            // Create shell if asked
            $forceShell = $this->modulable->getOption('shelled', true);
            if ($forceShell || $shell && Str::contains($command, $shelled)) {
                $command = $this->shellCommand($command);
            }

            if ($sudo && Str::contains($command, $sudoed)) {
                $command = $this->sudoCommand($sudo, $command);
            }
        }

        return $commands;
    }
666478
private function processCommands()
	{
		// Get all valid commands
		$this->getCommands();
		$commands = $this->_commands;

		// Sort commands
		sort($commands);

		// Build dimensional representation of commands
		$commands = $this->mergeCommands($commands);

		// Now output commands
		$this->addEntries($commands);
	}
233266
public function resolveCommands($commands)
    {
        return parent::resolveCommands(array_filter($commands, function ($command) {
            return is_subclass_of($command, TerminalCommand::class);
        }));
    }
1258533
def parse_commands(command)
      case command
      when Array
        command.map { |line| line.to_s }
      when String
        command.enum_for(:each_line).map { |line| line.chomp }
      else
        raise(InvalidConfig,"commands must be an Array or a String")
      end
    end
1139754
public function hydrateCommands(array $commands) : array
    {
        $modulesDone = [];

        foreach ($this->finder->getModuleList() as $module) {
            $moduleName = basename($module);

            if (!\in_array($moduleName, $modulesDone, true)) {
                $facade = Locator::getInstance()->{$moduleName}()->facade();
                if (method_exists($facade, 'getCommands')) {
                    $commands = \array_merge($commands, $facade->getCommands());
                }
                $modulesDone[] = $moduleName;
            }
        }

        return $commands;
    }
644429
public function toArray() : array {
        return [
            'command'   => $this->getCommand(),
            'running'   => $this->isRunning(),
            'info'      => $this->getInfo() ? $this->getInfo()->toArray() : null,
        ];
    }
78133
public static function loadCommands() {
		foreach (glob(__DIR__."/Console/Commands/*.php") as $filename) {
			$command = str_replace(".php","",str_replace(__DIR__."/Console/Commands/","",$filename));
			if ($command[0] != "_") {
				$commandClass = "\PatternLab\Console\Commands\\".$command;
				self::$commandInstances[] = new $commandClass();
			}
		}
	}
264792
public function execute ($command)
	{
		$retValue = $this->_conn->query($command)->fetchAll();

		if ($this->error($this->_conn->error()))
			return array();
		else
			return $retValue;
	}
938726
public function getCommand($command, $aliases = true)
    {
        if (array_key_exists($command, $this->commands)) {
            return $this->commands[$command];
        }

        if (array_key_exists($command, $this->aliases) && $aliases) {
            return $this->commands[$this->aliases[$command]];
        }
    }
813573
public function executeCommands(array $commands, \Closure $closure = null, Process $process = null)
    {
        foreach ($commands as $command => $commandClosure) {
            $currentClosure = (null !== $commandClosure) ? $commandClosure : $closure;
            $processResult = $this->executeCommand($command, $currentClosure, $process);
            if ($processResult === -1 || $processResult === 255) {
                return false;
            }
        }

        return true;
    }
1045033
def _process_commands(self, commands):
        """"""
        if commands is None:
            return
        for cmd_list in commands:
            try:
                cmd_list = split_command_line(cmd_list)
                cmd = cmd_list[0]
                if cmd == 'gdb_port':
                    if len(cmd_list) < 2:
                        LOG.error("Missing port argument")
                    else:
                        self._args.port_number = int(cmd_list[1], base=0)
                elif cmd == 'telnet_port':
                    if len(cmd_list) < 2:
                        LOG.error("Missing port argument")
                    else:
                        self._args.telnet_port = int(cmd_list[1], base=0)
                elif cmd == 'echo':
                    self.echo_msg = ' '.join(cmd_list[1:])
                else:
                    LOG.error("Unsupported command: %s" % ' '.join(cmd_list))
            except IndexError:
                pass
915479
private function process($command, array $data = [])
    {
        return $this->parse(
            $this->cURL(
                $this->queryString(
                    array_merge([
                        'command' => $command
                    ], $data)
                )
            )
        );
    }
140824
protected function registerCommands(array $commands)
    {
        foreach (array_keys($commands) as $command) {
            call_user_func([$this, "register{$command}Command"]);
        }

        $this->commands(array_values($commands));
    }
643423
protected static function execute($command)
    {
        $res = array();

        ob_start();
        passthru($command, $success);
        $output = ob_get_clean();

        foreach ((explode("\n", $output)) as $line) $res[] = trim($line);

        return array_filter($res);
    }
1004038
private function getColumnWidth(array $commands): int
	{
		$widths = [];

		foreach ($commands as $command)
		{
			if ($command instanceof AbstractCommand)
			{
				$widths[] = StringHelper::strlen($command->getName());

				foreach ($command->getAliases() as $alias)
				{
					$widths[] = StringHelper::strlen($alias);
				}
			}
			else
			{
				$widths[] = StringHelper::strlen($command);
			}
		}

		return $widths ? max($widths) + 2 : 0;
	}
1158534
protected function getColumnWidth(array $commands)
    {
        $width = 0;
        foreach ($commands as $command) {
            $aliasesString = $this->formatAliases($command->getAliases());
            $commandWidth = strlen($command->getName()) + strlen($aliasesString);
            $width = $commandWidth > $width ? $commandWidth : $width;
        }

        // Limit to a maximum.
        $terminalWidth = (new Terminal())->getWidth();
        if ($width / $terminalWidth > 0.4) {
            $width = floor($terminalWidth * 0.4);
        }

        // Start at a minimum.
        if ($width < 20) {
            $width = 20;
        }

        // Add the indent.
        $width += 2;

        // Accommodate tags.
        $width += strlen('<info></info>');

        return $width;
    }
594760
public function resolveCommands($commands)
    	{
    		$commands = Arrays::isArray($commands) ? $commands : func_get_args();

    		foreach ($commands as $command) {
    			$this->resolve($command);
    		}
    	}