#!/bin/python3

# This file is part of the Go-Smart Simulation Architecture (GSSA).
# Go-Smart is an EU-FP7 project, funded by the European Commission.
#
# Copyright (C) 2013-  NUMA Engineering Ltd. (see AUTHORS file)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This tool is a simple wrapper around the Comparator module, allowing two GSSA
# XMLs to be compared conceptually
from gssa.comparator import Comparator
import argparse


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("files", help="files to compare", metavar="FILE", type=str, nargs=2)
    args = parser.parse_args()

    # Open the files and pass their content to the comparator. We allow Python
    # to throw the exception through if there is a problem (nothing to add here)
    with open(args.files[0], 'r') as left, open(args.files[1], 'r') as right:
        comparator = Comparator(left.read(), right.read())

    # The Comparator object will return human readable strings from diff, so we
    # print these, one per line
    messages = comparator.diff()
    for message in messages:
        print(message)


if __name__ == '__main__':
    main()
