php-faketerm/bin/faketerm

30 lines
674 B
PHP
Executable File

#!/usr/bin/env php
<?php
use NoccyLabs\FakeTerm\FakeTerminal;
require_once __DIR__."/../vendor/autoload.php";
$opts = getopt("hf:o:v:");
$r = sprintf("%02x%02x", rand(0,255), rand(0,255));
$output = array_key_exists("o", $opts) ? $opts["o"] : "/tmp/ft_${r}_%04d.png";
$input = array_key_exists("f", $opts) ? $opts["f"] : null;
$video = array_key_exists("v", $opts) ? $opts["v"] : null;
if (!$input) {
fwrite(STDERR, "Error: Need to specify at least -f, preferably -o\n");
exit(1);
}
$ft = new FakeTerminal();
if ($video) {
printf("Rendering to video: %s\n", $video);
$ft->setOutputVideo($video);
}
$ft->setOutput($output);
$ft->executeFile($input);