| 409 | } |
| 410 | |
| 411 | int main(int argc, char** argv) { |
| 412 | try { |
| 413 | using namespace NLastGetopt; |
| 414 | TOpts opts = NLastGetopt::TOpts::Default(); |
| 415 | opts.AddHelpOption(); |
| 416 | |
| 417 | TString outputFileName; |
| 418 | TString outputHeaderFileName; |
| 419 | TString outputJsonFileName; |
| 420 | TString includePath; |
| 421 | opts.AddLongOption('o', "output").OptionalArgument("<output-file>").StoreResult(&outputFileName) |
| 422 | .Help( |
| 423 | "Output generated code to specified file.\n" |
| 424 | "When not set, standard output is used." |
| 425 | ); |
| 426 | opts.AddLongOption('h', "header").OptionalArgument("<output-header>").StoreResult(&outputHeaderFileName) |
| 427 | .Help( |
| 428 | "Generate appropriate header to specified file.\n" |
| 429 | "Works only if output file specified." |
| 430 | ); |
| 431 | opts.AddLongOption("include-path").OptionalArgument("<header-path>").StoreResult(&includePath) |
| 432 | .Help( |
| 433 | "Include input header using this path in angle brackets.\n" |
| 434 | "When not set, header basename is used in double quotes." |
| 435 | ); |
| 436 | |
| 437 | opts.AddLongOption('j', "json-output").OptionalArgument("<json-output>").StoreResult(&outputJsonFileName) |
| 438 | .Help( |
| 439 | "Generate enum data in JSON format." |
| 440 | ); |
| 441 | |
| 442 | opts.SetFreeArgsNum(1); |
| 443 | opts.SetFreeArgTitle(0, "<input-file>", "Input header file with enum declarations"); |
| 444 | |
| 445 | TOptsParseResult res(&opts, argc, argv); |
| 446 | |
| 447 | TVector<TString> freeArgs = res.GetFreeArgs(); |
| 448 | TString inputFileName = freeArgs[0]; |
| 449 | |
| 450 | THolder<IOutputStream> hOut; |
| 451 | IOutputStream* out = &Cout; |
| 452 | |
| 453 | THolder<IOutputStream> headerOut; |
| 454 | |
| 455 | THolder<IOutputStream> jsonOut; |
| 456 | |
| 457 | |
| 458 | if (outputFileName) { |
| 459 | NFs::Remove(outputFileName); |
| 460 | hOut.Reset(new TFileOutput(outputFileName)); |
| 461 | out = hOut.Get(); |
| 462 | |
| 463 | if (outputHeaderFileName) { |
| 464 | headerOut.Reset(new TFileOutput(outputHeaderFileName)); |
| 465 | } |
| 466 | |
| 467 | if (outputJsonFileName) { |
| 468 | jsonOut.Reset(new TFileOutput(outputJsonFileName)); |
nothing calls this directly
no test coverage detected