2024-10-01 18:46:03 +02:00
|
|
|
<?php
|
|
|
|
|
|
2024-10-02 01:15:22 +02:00
|
|
|
use NoccyLabs\JsonEdit\Settings;
|
2024-10-02 00:53:11 +02:00
|
|
|
|
2024-10-01 18:46:03 +02:00
|
|
|
require_once __DIR__."/../vendor/autoload.php";
|
|
|
|
|
|
2024-10-02 00:53:11 +02:00
|
|
|
define("SETTINGS_FILE", getenv("HOME")."/.config/jsonedit/config.json");
|
|
|
|
|
|
|
|
|
|
$filename = $argv[1]??null;
|
2024-10-01 18:46:03 +02:00
|
|
|
|
2024-10-02 01:15:22 +02:00
|
|
|
$terminal = new NoccyLabs\JsonEdit\Terminal\Terminal();
|
2024-10-01 18:46:03 +02:00
|
|
|
|
2024-10-02 00:53:11 +02:00
|
|
|
Settings::load(SETTINGS_FILE);
|
|
|
|
|
|
2024-10-02 01:15:22 +02:00
|
|
|
$editor = new NoccyLabs\JsonEdit\Editor\Editor($terminal);
|
2024-10-01 18:46:03 +02:00
|
|
|
if ($filename) {
|
|
|
|
|
$editor->loadFile($filename);
|
|
|
|
|
} else {
|
|
|
|
|
$editor->loadDocument((object)[]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_exception_handler(function (\Throwable $t) use ($terminal) {
|
|
|
|
|
register_shutdown_function(function () use ($t, $terminal) {
|
|
|
|
|
$terminal->shutdown();
|
|
|
|
|
echo $t."\n";
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$editor->run();
|