Open agung-wete opened 10 years ago
Does this happen with the examples in /examples?
yes
Does this lib support windows env? I imagine that would be quite difficult to create parallel feature support
I don't have a windows machine or VM handy to debug. Might have something to do with the Colors.php library. Have you tried running examples directly from the Colors.php library?
Hi, This is happening to me as well. It looks like its coming from Terminal::tput().
Specifically I think the issue is that /dev/null
cannot be found in the Windows environment (the Terminal::tput()
method redirects to /dev/null
).
I created a C:\dev\null
folder on the Windows box I am working with to see what would happen. I then started getting "Access is denied" messages instead of "The system cannot find the path specified."
This happens when executing "tput" to get the width of the terminal in Terminal.php line 51 ff.
private static function tput($default, $param = 'cols')
{
$test = exec('tput ' . $param . ' 2>/dev/null');
if (empty($test))
return $default;
$result = intval(exec('tput ' . $param));
return empty($result) ? $default : $result;
}
It would be more optimal if at first the os is detected with the PHP_OS constant and check for the first 3 characters = "WIN". Even for Linux environments it could be optimal to execute "which tput" at first to see if it's there and accessible. For Win Environments I think there is not an optimal way to get the width. I think it's best to execute "MODE CON:" as this is available in every Windows installation (I think even since MS-DOS 3.3 :) ) The returned string gives console parameters like the width, lines and so on. But the output is language dependent. So in my German installation something like:
Status von Gerät CON:
---------------------
Zeilen: 300
Spalten: 99
Wiederholrate: 31
Verzögerungszeit:1
Codepage: 850
So you'd have to maybe regex to get the second line after "-----".
I think the tput function could be optimized like the following. It's working good in my environment.
private static function tput($default, $param = 'cols')
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
return $default;
$path = trim(shell_exec('which tput'));
if (empty($path))
return $default;
$test = exec('tput ' . $param . ' 2>/dev/null');
if (empty($test))
return $default;
$result = intval(exec('tput ' . $param));
return empty($result) ? $default : $result;
}
Maybe you can import the changes...
Hi
Using windows environment try to use --help, got this errors, just right before filename appeared=
Yes, 3 in a row.
Thanks