Beispiel #1
0
 static void Main(string[] args)
 {
     try
     {
         ResourceTree tree;
         if (args.Length == 0 || args[0] == "-h")
         {
             Usage(System.AppDomain.CurrentDomain.FriendlyName);
             return;
         }
         else if (args[0] == "-f")
         {
             var file = args[1];
             tree = YamlLexer.LoadResourcesFromFile(file);
         }
         else
         {
             tree = CommandLineLexer.LexCommandLine(args);
         }
         var context  = Parser.Parse(tree);
         var injector = new Injector(context);
         injector.Inject();
         var generate = new Generate(context);
         Console.WriteLine(generate.BuildString());
     }
     catch (Exception exception)
     {
         if (exception.GetType().IsSubclassOf(typeof(FunctionalException)))
         {
             Console.Error.WriteLine($"{exception.GetType().Name}: {exception.Message}");
         }
         else if (exception.InnerException != null && exception.InnerException.GetType().IsSubclassOf(typeof(FunctionalException)))
         {
             Console.Error.WriteLine($"{exception.InnerException.GetType().Name}: {exception.InnerException.Message}");
         }
         else
         {
             Console.Error.WriteLine($"{exception.ToString()}");
         }
     }
 }