aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Program.cs
blob: 742b1428d79a246bb234dee79723a12fcd36be72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Helpers;
using Tango.DAL.Observables;

namespace Tango.DBObservablesGenerator.CLI
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                if (args == null || args.Length == 0)
                {
                    ExitError("Invalid arguments!");
                }

                String targetPath = args[0];

                ObservablesGenerator generator = new ObservablesGenerator();

                foreach (var file in Directory.GetFiles(targetPath))
                {
                    PathHelper.TryDeleteFile(file);
                }

                try
                {
                    generator.Generate(targetPath);
                }
                catch (Exception ex)
                {
                    ExitError(ex.ToString());
                }

                ExitSuccess("Tango DAL observables generated on: '" + targetPath + "'\nPlease build again to ensure compatibility.");
            }
            catch
            {
                ExitSuccess("Tango DAL observables generation skipped! Try Build again...");
            }
        }

        private static void ExitError(String error)
        {
            Console.WriteLine(error);
            Environment.Exit(-1);
        }

        private static void ExitSuccess(String text)
        {
            Console.WriteLine(text);
            Environment.Exit(0);
        }
    }
}