| 6 | #include <iostream> |
| 7 | |
| 8 | int main(int argc, char ** argv) |
| 9 | { |
| 10 | auto const ShowUsage = [argv]() |
| 11 | { |
| 12 | std::cout << "Usage: " << argv[0] |
| 13 | << " make|apply olderMWMPath newerMWMPath diffPath\n" |
| 14 | "make\n" |
| 15 | " Creates the diff between newer and older MWMs at `diffPath`\n" |
| 16 | "apply\n" |
| 17 | " Applies the diff at `diffPath` to the mwm at `olderMWMPath` and stores result at `newerMWMPath`.\n" |
| 18 | "WARNING: THERE IS NO MWM VALIDITY CHECK!\n"; |
| 19 | }; |
| 20 | |
| 21 | if (argc < 5) |
| 22 | { |
| 23 | ShowUsage(); |
| 24 | return -1; |
| 25 | } |
| 26 | |
| 27 | auto const IsEqualUsage = [argv](char const * s) { return 0 == std::strcmp(argv[1], s); }; |
| 28 | char const *olderMWMPath{argv[2]}, *newerMWMPath{argv[3]}, *diffPath{argv[4]}; |
| 29 | |
| 30 | if (IsEqualUsage("make")) |
| 31 | { |
| 32 | if (generator::mwm_diff::MakeDiff(olderMWMPath, newerMWMPath, diffPath)) |
| 33 | return 0; |
| 34 | } |
| 35 | else if (IsEqualUsage("apply")) |
| 36 | { |
| 37 | base::Cancellable cancellable; |
| 38 | auto const res = generator::mwm_diff::ApplyDiff(olderMWMPath, newerMWMPath, diffPath, cancellable); |
| 39 | if (res == generator::mwm_diff::DiffApplicationResult::Ok) |
| 40 | return 0; |
| 41 | } |
| 42 | else |
| 43 | ShowUsage(); |
| 44 | |
| 45 | return -1; // Failed, Cancelled. |
| 46 | } |