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