1
0
mirror of https://github.com/ErnyTech/TLScheme2Json synced 2024-11-11 13:49:23 +01:00
TLScheme2Json/source/app.d
2019-05-11 00:15:06 +02:00

69 lines
2.1 KiB
D

/* Copyright 2019 Ernesto Castellotti <erny.castell@gmail.com>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* Appendix by copyright onwer:
* All files or characters displayed on the screen generated by this program are
* to be considered as the property of the copyright owner, any use (including commercial)
* is permitted on the condition of publicly mentioning the use of this software.
*/
void main(string[] args) {
import tlscheme2json : TLScheme2Json;
import std.getopt : getopt;
import std.getopt : config;
import std.array : empty;
import std.file : readText;
import std.stdio : File;
import std.file : write;
import std.stdio : writeln;
string tlFile;
string outFile;
string jsonScheme;
auto cmd = getopt(
args,
"tl", &tlFile,
"output", &outFile
);
if (tlFile.empty) {
auto parser = new TLScheme2Json();
parser.parse;
jsonScheme = parser.toJson;
} else {
auto tl = readText(tlFile);
auto parser = new TLScheme2Json(tl);
parser.parse;
jsonScheme = parser.toJson;
}
if (!outFile.empty) {
auto file = File(outFile, "w");
scope(exit) file.close;
file.write(jsonScheme);
} else {
writeln(jsonScheme);
writeln("----------");
}
writeln("LICENSE:
Copyright 2019 Ernesto Castellotti <erny.castell@gmail.com>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
Appendix by copyright onwer:
All files or characters displayed on the screen generated by this program
are to be considered as the property of the copyright owner, any use (including commercial)
is permitted on the condition of publicly mentioning the use of this software.");
if (!outFile.empty) {
writeln();
writeln("[OK] Scheme generated to " ~ outFile ~ " !!");
}
}