| 6 | using namespace OpenApoc; |
| 7 | |
| 8 | int main(int argc, char *argv[]) |
| 9 | { |
| 10 | config().addPositionalArgument("image_string", "Image string to read"); |
| 11 | config().addPositionalArgument("output_file", "Output .png file"); |
| 12 | |
| 13 | if (config().parseOptions(argc, argv)) |
| 14 | { |
| 15 | return EXIT_FAILURE; |
| 16 | } |
| 17 | |
| 18 | auto outputFile = config().getString("output_file"); |
| 19 | auto inputString = config().getString("image_string"); |
| 20 | |
| 21 | if (inputString.empty()) |
| 22 | { |
| 23 | std::cerr << "Must provide image_string\n"; |
| 24 | config().showHelp(); |
| 25 | return EXIT_FAILURE; |
| 26 | } |
| 27 | |
| 28 | if (outputFile.empty()) |
| 29 | { |
| 30 | std::cerr << "Must provide output_file\n"; |
| 31 | config().showHelp(); |
| 32 | return EXIT_FAILURE; |
| 33 | } |
| 34 | |
| 35 | Framework f(UString(argv[0]), false); |
| 36 | |
| 37 | auto img = f.data->loadImage(inputString); |
| 38 | if (!img) |
| 39 | { |
| 40 | std::cerr << "Failed to load image \"" << inputString << "\"\n"; |
| 41 | return EXIT_FAILURE; |
| 42 | } |
| 43 | |
| 44 | if (!f.data->writeImage(outputFile, img)) |
| 45 | { |
| 46 | std::cerr << "Failed to write output file \"" << outputFile << "\"\n"; |
| 47 | return EXIT_FAILURE; |
| 48 | } |
| 49 | |
| 50 | return EXIT_SUCCESS; |
| 51 | } |
nothing calls this directly
no test coverage detected