From 5bf20a8a1bd331c1f8e36212cffde2c0d6f94c9d Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Tue, 26 Aug 2025 11:57:39 +0200 Subject: add it::gets_all variant of it::gets --- it.class | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/it.class b/it.class index 88724b1..ebdaf6e 100644 --- a/it.class +++ b/it.class @@ -1020,6 +1020,22 @@ static function _stdin_next() return $result; } +/** + * 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. -- cgit v1.2.3