From: Nicolas Boisselier Date: Wed, 6 Dec 2017 05:41:29 +0000 (+0000) Subject: bin/nb-stdin X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=905268e9dfceb64f55c564e1cd48628130201c9e;p=nb.git bin/nb-stdin --- diff --git a/bin/nb-stdin b/bin/nb-stdin new file mode 100755 index 00000000..717db944 --- /dev/null +++ b/bin/nb-stdin @@ -0,0 +1,32 @@ +#!/usr/bin/env php + +* +* bin/nb-stdin +*/ +require_once(dirname(__FILE__).'/../lib/php/nb.php'); +define(NAME,$argv[0]); array_shift($argv); + +$NB = new NB(); + +#$data = stream_get_contents(STDIN); +while($line = fgets(STDIN)) { + $line = rtrim($line); + + foreach ($argv as $fct) { + + if ($fct === 'cat') { + if ($line) $line = file_get_contents($line); + + } else { + $line = $NB->$fct($line); + + } + + } + + echo $line."\n"; +} +?>