aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/Program.cs
blob: cc0bbf1596d1b4f26be75ee27602a8f424b2cca0 (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
62
63
64
65
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Helpers;

namespace Tango.DBObservablesGenerator.CLI
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.Title = "Tango Observables Generator";

                if (args == null || args.Length < 2)
                {
                    ExitError("Invalid arguments!");
                }

                String targetPath = args[0];
                String language = args[1];

                ObservablesGenerator generator = new ObservablesGenerator();

                try
                {
                    if (language.ToLower() == "-csharp")
                    {
                        generator.GenerateCSharp(targetPath);
                    }
                    else if (language.ToLower() == "-java")
                    {
                        generator.GenerateJava(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);
        }
    }
}