Returns whether the launcher is supported on the current system.
public isSupported ( ) : boolean | ||
return | boolean | Whether the launcher is supported on the current system. |
/** * {@inheritdoc} */ public function handle() { if (!$this->processLauncher->isSupported()) { throw new RuntimeException('The ProcessLauncher must be supported for the man help to run.'); } if (!$this->manBinary) { $this->manBinary = $this->executableFinder->find('man'); } if (!$this->manBinary) { throw new RuntimeException('The "man" binary was not found.'); } return $this->processLauncher->launchProcess(escapeshellcmd($this->manBinary) . ' -l %path%', array('path' => $this->path), false); }
/** * {@inheritdoc} */ public function handle(Args $args, IO $io) { if ($this->processLauncher->isSupported()) { if (!$this->lessBinary) { $this->lessBinary = $this->executableFinder->find('less'); } if ($this->lessBinary) { return $this->processLauncher->launchProcess(escapeshellcmd($this->lessBinary) . ' %path%', array('path' => $this->path), false); } } $io->write(file_get_contents($this->path)); return 0; }
/** * Callback for selecting the handler that should be run. * * @param Args $args The console arguments. * @param IO $io The I/O. * @param Command $command The handled command. * * @return string The name of the handler to run. */ public function getHandlerToRun(Args $args, IO $io, Command $command) { $rawArgs = $args->getRawArgs(); // The raw arguments should always be available, but check anyway if (!$rawArgs) { return 'text'; } // If "-h" is given, always print the short text usage if ($rawArgs->hasToken('-h')) { return 'text'; } // Check if any of the options is set foreach ($this->getRegisteredNames() as $handlerName) { if ($rawArgs->hasToken('--' . $handlerName)) { return $handlerName; } } // No format option is set, "-h" is not set // If a command is given or if "--help" is set, display the manual if ($rawArgs->hasToken('--help')) { // Return "man" if the binary is available and the man page exists // The process launcher must be supported on the system $manPage = $this->getManPage($command->getApplication(), $args); if (file_exists($manPage) && $this->processLauncher->isSupported()) { if (!$this->manBinary) { $this->manBinary = $this->executableFinder->find('man'); } if ($this->manBinary) { return 'man'; } } // Return "ascii-doc" if the AsciiDoc page exists $asciiDocPage = $this->getAsciiDocPage($command->getApplication(), $args); if (file_exists($asciiDocPage)) { return 'ascii-doc'; } } // No command, no option -> display command list as text return 'text'; }