diff options
author | Nathan Gass | 2025-08-26 11:57:39 +0200 |
---|---|---|
committer | Nathan Gass | 2025-08-26 12:07:42 +0200 |
commit | 5bf20a8a1bd331c1f8e36212cffde2c0d6f94c9d (patch) | |
tree | 93690529c73b80f75bb676710cb0e11f007de7af /it.class | |
parent | 90a3b712e4f5df5832f219562703af4d43b1ae06 (diff) | |
download | itools-5bf20a8a1bd331c1f8e36212cffde2c0d6f94c9d.tar.gz itools-5bf20a8a1bd331c1f8e36212cffde2c0d6f94c9d.tar.bz2 itools-5bf20a8a1bd331c1f8e36212cffde2c0d6f94c9d.zip |
add it::gets_all variant of it::gets
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1021,6 +1021,22 @@ static function _stdin_next() } /** + * Get all lines from command line arguments or stdin. + * Transparently reads existing files in the command line arguments and passes on all other arguments. + * Note: You need to call getopt() before using this function. + */ +static function gets_all() +{ + while (it::_stdin_next()) { + if (($fd = $GLOBALS['it_stdin']['fd'])) + while ($line = fgets($fd)) + yield rtrim($line, "\n"); + else + yield $GLOBALS['it_stdin']['filename']; + } +} + +/** * Get one line from stdin (or files given on command line) a la Perl <>. * Note: You need to call getopt() before using this function. * @return Line (including newline) or false on eof |