<?php if (!isset($argv[1])) { exit_with_error('input file not specified in first arguement'); } $init = new Init($argv[1], dirname(__DIR__) . '/InitializerExtension.swift'); $init->create_init_file(); class Init { private $json; private $jsonFileLocation; private $out; public function __construct($jsonFileLocation, $outputFile) { $this->jsonFileLocation = $jsonFileLocation; $this->json = json_decode(file_get_contents(realpath($jsonFileLocation)), true); $this->out = fopen($outputFile, 'w'); if (!is_array($this->json)) { fclose($this->out); exit_with_error('invalid json file'); } if ($this->out === false) { exit_with_error('could not open output file ./InitializerExtension.swift'); } } /** * Can only call create_init_file() once per lifecycle */ public function create_init_file() { $this->print('// this file is auto-generated, do not edit it.', 0);