using System;
using Электронная_Фармация.Classes;

namespace UpdateCheckSmoke
{
    internal static class Program
    {
        private static int Main(string[] args)
        {
            // args: baseUrl repo localVersion
            var baseUrl = args.Length > 0 ? args[0] : "http://127.0.0.1:18765";
            var repo = args.Length > 1 ? args[1] : "pharmdata/elfisa-pharmacy";
            var local = args.Length > 2 ? args[2] : "1.0.3.0";

            var result = UpdateChecker.CheckForUpdate(baseUrl, repo, null, local);
            Console.WriteLine("CheckedOk=" + result.CheckedOk);
            Console.WriteLine("UpdateRequired=" + result.UpdateRequired);
            Console.WriteLine("Local=" + result.LocalVersion);
            Console.WriteLine("Latest=" + result.LatestVersion);
            Console.WriteLine("Download=" + result.DownloadUrl);
            Console.WriteLine("Error=" + result.ErrorMessage);

            if (!result.CheckedOk)
            {
                return 2;
            }

            return result.UpdateRequired ? 0 : 1;
        }
    }
}
