nur-ture/src/tools/Json2yamlApp.php

23 lines
452 B
PHP

<?php
namespace nulib\tools;
use nulib\app\cli\Application;
use nulib\ext\json;
use nulib\ext\yaml;
use nulib\os\path;
class Json2yamlApp extends Application {
private $args;
function main() {
$input = $this->args[0] ?? null;
if ($input === null || $input === "-") {
$output = null;
} else {
$output = path::ensure_ext($input, ".yml", ".json");
}
$data = json::load($input);
yaml::dump($data, $output);
}
}