git-svn-id: svn://db.shs.com.ru/pip@557 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-11-20 19:53:28 +00:00
parent a3d9dce7c5
commit fde7d7bc80
9 changed files with 240 additions and 2 deletions

View File

@@ -0,0 +1,64 @@
#include "parser.h"
#include "generator.h"
#include "picli.h"
using namespace PICoutManipulators;
void usage() {
piCout << Bold << "PIP Resources Compiler";
piCout << Cyan << "Version" << Bold << PIPVersion() << NewLine;
piCout << Green << Bold << "Usage:" << Default << "\"pirc [-h] -i <in_file> -o <out_file>\"" << NewLine;
piCout << Green << Bold << "Details:";
piCout << "-h --help " << Green << "- display this message and exit";
piCout << "-i --input <in_file> " << Green << "- resources description file";
piCout << "-o --out <out_file> " << Green << "- output .cpp file";
}
int main (int argc, char * argv[]) {
PICLI cli(argc, argv);
cli.addArgument("input", true);
cli.addArgument("out", true);
cli.addArgument("help");
if (!cli.hasArgument("input") ||
!cli.hasArgument("out") ||
cli.hasArgument("help")) {
usage();
return 0;
}
//piCout << "args:" << cli.rawArguments();
PIVector<ParserSection> files = parse(cli.argumentValue("input"));
if (files.isEmpty()) {
piCout << "Error: resources description file is empty";
return 0;
}
/*piForeachC (ParserSection & s, files) {
piCout << "[" << s.name << "]";
piCout << s.files;
}*/
PIString out_file = cli.argumentValue("out");
PIFile outf;
if (!out_file.isEmpty()) {
if (outf.open(out_file, PIIODevice::ReadWrite)) {
outf.clear();
} else piCout << "Error: while open out file";
outf << "// Generated by \"PIP Resources Compiler\" " << PIDateTime::current().toString("dd.MM.yyyy hh:mm:ss\n");
outf << "// Execute command:\n";
piForeachC (PIString & _a, cli.rawArguments())
outf << "// \"" << _a << "\"\n";
outf << "\n";
//outf << "#include \"pivariant.h\"\n#include \"picodeinfo.h\"";
if (!generate(outf, files)) {
piCout << "Error: generate fail";
return 1;
}
}
return 0;
}