forked from stechstudio/bai2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbai2json
executable file
·33 lines (28 loc) · 1.26 KB
/
bai2json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env php
<?php
declare(strict_types=1);
// autoload dance /////////////////////////////////////////////////////
//
$autoload = dirname(__DIR__) . '/vendor/autoload.php'; //
if (!is_file($autoload)) { //
$autoload = dirname(__DIR__, 4) . '/vendor/autoload.php'; //
if (!is_file($autoload)) { //
die("Unable to find Composer autoload file."); //
} //
} //
//
require $autoload; //
//
///////////////////////////////////////////////////////////////////////
use STS\Bai2\Bai2;
use STS\Bai2\Records\FileRecord;
function read(string $filename): FileRecord
{
if ($filename == '-') {
return Bai2::parse(STDIN);
} else {
return Bai2::parse($filename);
}
}
$fileRecord = read($argv[1] ?? '-');
echo json_encode($fileRecord->toArray());