/** * Get the built command * * @return string */ public function getBuiltCommand() { $cmd = $this->command; foreach ($this->arguments as $argument) { $os = $argument->getOs(); if ($os && !($os & $this->os->getType())) { continue; } $key = $argument->getKey(); $prefix = $argument->getPrefix(); if ($argument->willEscape() === true || $argument->willEscape() === null && $this->flags & ESCAPE) { $key = $this->escapeshellarg($key); } $key = $prefix . $key; $values = $argument->getValues(); if (empty($values)) { $cmd .= " {$key}"; continue; } foreach ($values as $val) { $cmd .= " {$key}"; $cmd .= $this->flags & DONT_ADD_SPACE_BEFORE_VALUE ? '' : ' '; if ($argument->willEscape() === true || $argument->willEscape() === null && $this->flags & ESCAPE) { $val = $this->escapeshellarg($val); } $cmd .= $val; } } return trim($cmd); }
/** * Find the right command to launch a url on a platform. * @param string $url * @return string */ protected function getBrowserCommand($url) { // Mac if (\Tivie\OS\MACOSX == $this->os->getType()) { return "open {$url}"; } // Windows if ($this->os->isWindowsLike()) { return "start {$url}"; } // everything else (most likely unix) return "xdg-open {$url}"; }