Check if a native command is available.

@param string $command

@return bool
778081
public function isNativeCommandAvailable($command)
    {
        switch ($command) {
            case 'zip':
            case 'unzip':
                break;
            default:
                return false;
        }
        if (!isset($this->availableNativeCommands[$command])) {
            $this->availableNativeCommands[$command] = false;
            if ($this->functionInspector->functionAvailable('exec')) {
                $rc = 1;
                $output = [];
                @exec($command . ' -v 2>&1', $output, $rc);
                if ($rc === 0) {
                    $stdOut = implode("\n", $output);
                    if (stripos($stdOut, 'info-zip') !== false || stripos($stdOut, 'infozip') !== false) {
                        $this->availableNativeCommands[$command] = true;
                    }
                }
            }
        }

        return $this->availableNativeCommands[$command];
    }
1356319
public function exec($command)
    {
        // Check for prohibited commands
        foreach ($this->prohibitedCommands as $prohibitedCommand) {
            if (strpos(trim($command), $prohibitedCommand) !== false) {
                throw new \Exception('The shell command ' . $command . ' is prohibited');
            }
        }
        return exec($command);
    }
862620
public function resolveCommand($command)
    {
        if ($fullPaths = $this->findWhere($command)) {
            $fullPaths = preg_split('/[\r\n]/', trim($fullPaths));
            $command = end($fullPaths);
        }

        return $command;
    }
1077481
public function findHandler(Command $command)
    {
        $command_name = get_class($command);

        return isset($this->handlers[$command_name]) ? $this->handlers[$command_name] : null;
    }
247527
protected function isCommandDisabled($command) {
    $disabled_commands = $this->getDisabledCommands();
    if (is_array($disabled_commands) && array_key_exists($command, $disabled_commands) && $disabled_commands[$command]) {
      $this->logger->warning("The $command command is disabled.");
      return TRUE;
    }

    return FALSE;
  }
575247
public function getCommandHandler($command)
    {
        if ($this->hasCommandHandler($command)) {
            return $this->container->make($this->handlers[get_class($command)]);
        }

        return false;
    }
631749
protected function isCmsEnabledArtisanCommand()
    {
        if (null !== $this->registeredConsoleCommand) {
            // @codeCoverageIgnoreStart
            return $this->registeredConsoleCommand;
            // @codeCoverageIgnoreEnd
        }

        if ( ! $this->isConsole()) {
            $this->registeredConsoleCommand = false;
            return false;
        }

        $command = $this->getArtisanBaseCommand();

        // If no command is given, the CMS will be loaded, to make
        // sure that its commands will appear in the Artisan list.
        if (empty($command)) {
            $this->registeredConsoleCommand = true;
            return true;
        }

        $patterns = $this->getCmsEnabledArtisanPatterns();

        foreach ($patterns as $pattern) {
            if ($command === $pattern || Str::is($pattern, $command)) {
                $this->registeredConsoleCommand = true;
                return true;
            }
        }

        $this->registeredConsoleCommand = false;
        return false;
    }
1082630
protected function runCommand($command)
    {
        $process = new Process($command);

        $process->run();

        if ( ! $process->isSuccessful()) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return $process->getExitCode();
    }
1191884
protected function runCommand($command)
    {
        $method = 'image' . ucfirst(strtolower($command['command']));
        if (!method_exists($this, $method)) {
            return false;
        }
        call_user_func_array([$this, $method], $command['params']);
        
        return true;
    }
723578
private static function areCommands(array $commands): bool
    {
        $areCommands = true;

        foreach ($commands as $command) {
            $areCommands = $areCommands && ($command instanceof BaseCommand);
        }

        return $areCommands;
    }
1271716
public function hasCommand($name = '') {
        if ($name) {
            return array_key_exists($name, $this->commandSchemas);
        } else {
            foreach ($this->commandSchemas as $pattern => $opts) {
                if (strpos($pattern, '*') === false) {
                    return true;
                }
            }
            return false;
        }
    }
214842
def command_exists(command):
    
    for category, commands in iteritems(command_categories):
        for existing_command in commands:
            if existing_command.match(command):
                return True
    return False
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);
    }
684671
public function processCommand($command)
    {
        // Add environment flag to commands
        $stage = $this->connections->getCurrentConnectionKey()->stage;
        if (Str::contains($command, 'artisan') && $stage) {
            $command .= ' --env="'.$stage.'"';
        }

        return $command;
    }
1203151
public function getProvider($command)
    {
        $providerExists = (isset($this->providers[$command]) && class_exists($this->providers[$command]));
        return ($providerExists) ? new $this->providers[$command] : false;
    }
86363
private function isCommandCacheable(Command $command)
    {
        $className = get_class($command);

        return isset(self::$commandsToCache[$className]);
    }
1074811
public function rejectCommand($command)
    {
        $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
        if (defined('HHVM_VERSION')) {
            $binary .= ' --php';
        }

        if (defined('ARTISAN_BINARY')) {
            $artisan = ProcessUtils::escapeArgument(ARTISAN_BINARY);
        } else {
            $artisan = 'artisan';
        }
        return trim(str_replace([$binary, $artisan], '', $command));
    }