/** * Display an error message using red color on the console to make it * easier to spot. * * @param string $error * @returns RendererInterface */ public function error($error) { echo PHP_EOL; $this->console->writeLine('ERROR: ' . $error . PHP_EOL, Color::calculate('ff0000')); echo PHP_EOL; return $this; }
/** * Determine and return current console height. * * @return false|int */ public function getHeight() { static $height; if ($height > 0) { return $height; } // Try to read console size from ANSICON env var if (preg_match('/\\(\\d+x(\\d+)/', getenv('ANSICON'), $matches)) { $height = $matches[1]; } else { $height = AbstractAdapter::getHeight(); } return $height; }
/** * Determine and return current console height. * * @return false|int */ public function getHeight() { static $height; if ($height > 0) { return $height; } // Try to read console size from "mode" command if ($this->modeResult === null) { $this->runProbeCommand(); } if (preg_match('/Rows\\:\\s+(\\d+)/', $this->modeResult, $matches)) { $height = $matches[1]; } else { $height = parent::getHeight(); } return $height; }
/** * Determine and return current console height. * * @return false|int */ public function getHeight() { static $height; if ($height > 0) { return $height; } // Try to read env variable if (($result = getenv('LINES')) !== false) { return $height = (int) $result; } // Try to read console size from "tput" command $result = exec('tput lines', $output, $return); if (!$return && is_numeric($result)) { return $height = (int) $result; } return $height = parent::getHeight(); }
/** * @param $question * @param ConsoleAdapter $console * * @return string|null */ private function askUrlQuestion($question, ConsoleAdapter $console) { $console->writeLine($question . ' (URL)', ColorInterface::CYAN); $prompt = new Line(''); $prompt->setConsole($console); $url = $prompt->show(); if (!(new Uri(['allowRelative' => false]))->isValid($url)) { $console->writeLine('The provided URL "' . $url . '" doesn\'t seem to be valid!', ColorInterface::RED); return null; } return $url; }