Changeset View
Changeset View
Standalone View
Standalone View
src/console/PhutilConsoleMetrics.php
Show All 40 Lines | if (phutil_is_windows()) { | ||||
// TODO: Figure out how to do this on Windows. | // TODO: Figure out how to do this on Windows. | ||||
return null; | return null; | ||||
} | } | ||||
$tmp = new TempFile(); | $tmp = new TempFile(); | ||||
// NOTE: We can't just execute this because it won't be connected to a TTY | // NOTE: We can't just execute this because it won't be connected to a TTY | ||||
// if we do. | // if we do. | ||||
$err = id(new PhutilExecPassthru('tput cols > %s', $tmp)) | $err = (new PhutilExecPassthru('tput cols > %s', $tmp)) | ||||
->resolve(); | ->resolve(); | ||||
$stdout = Filesystem::readFile($tmp); | $stdout = Filesystem::readFile($tmp); | ||||
unset($tmp); | unset($tmp); | ||||
if ($err) { | if ($err) { | ||||
return null; | return null; | ||||
} | } | ||||
$width = (int)trim($stdout); | $width = (int)trim($stdout); | ||||
if ($width > 0) { | if ($width > 0) { | ||||
return $width; | return $width; | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0