Closed Hywan closed 8 years ago
@jubianchi, @Metalaka: Please, review it. I will add tests today.
Ready for a review!
I found a way to solve the issue -f
vs. -F
(respectively on BSD and Linux). See the commit message of https://github.com/Hywan/Console/commit/402b21835aa907e1df333e2b79c3f7c9fb5831b2:
On Linux, this is the
stty -F $file
orstty --file $file
options. On BSD, this is thestty -f $file
option.There is a conflict here and this is difficult to have something cross-platform. Fortunately, both architectures use the standard input as the
-F
,--file
or-f
value. So writingstty < $file
seems to fix the issue.
We are ready for a merge. @Metalaka, @jubianchi: Is it OK for you?
getStream
issue not solved, see example on https://github.com/hoaproject/Stream/issues/16
I guess we can merge this patch before, though? This is safe enough for now.
Ok, let's go.
We still have an issue with stty -f
, -F
and <
…
Fixed with this commit.
Old title
Imagine this case:
where
foo.php
is a program that reads fromSTDIN
. It works perfectly withHoa\Console
.Now, imagine this other case:
STDIN
will containfoo
andbar
but theHoa\Console\Cursor
—for instance— will no longer work since it reads fromSTDIN
too.The idea is then to close
STDIN
(akaphp://input
) and open/dev/tty
, which is the real standard input in this case.So, to address these needs, we introduce the
Hoa\Console::getStdin
method that is a helper to choose the appopriate standard input. We also change theHoa\Console::advancedInteraction
behavior: 👷stty
uses the-f
option to specify/dev/tty
instead of the default standard input. However, on Linux, this is-F
. I don't know how to address this right now (I mean: Making something cross-platform).Finally, all
Hoa\Console
's classes that were usingSTDIN
directly are now usingHoa\Console::getStdin
.New title
Actually, since #55, this PR has taken a new path. We also introduced an
Input
class. And it considers whether to useHoa\File\Read('php://stdin')
as the default input, orHoa\File\Read('/dev/tty')
in case the former has been closed. This is a basic wrapper.