public static int Main(string[] args) { AppInfo(); var result = 1; try { ArgumentsParser.Parse(args, out var files, out var convert, out bool _, out var outputDirectory); if (!convert) { var compilerParameters = GetCompilerParameters(files, outputDirectory); var compiler = new SyntactikCompiler(compilerParameters); var context = compiler.Run(); if (context.Errors.Count > 0) { PrintCompilerErrors(context.Errors); return(1); } } else { foreach (var file in files) { if (file.EndsWith(".xml")) { string s = ConvertXml(File.ReadAllText(file), 0, ' ', 2); File.WriteAllText(Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(file) + ".s4x"), s); } else if (file.EndsWith(".json")) { string s = ConvertJson(File.ReadAllText(file), 0, ' ', 2); File.WriteAllText(Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(file) + ".s4j"), s); } } } result = 0; } catch (ArgumentsParserException e) { Console.WriteLine("Fatal error: {0}", e.Message); ArgumentsParser.Help(); AppInfo2(); } catch (Exception e) { Console.WriteLine("Fatal error: {0}", e.Message); Console.WriteLine(e.StackTrace); } return(result); }
public static int Main(string[] args) { AppInfo(); var result = 1; try { bool recursive; List <string> files; string outputDirectory; ArgumentsParser.Parse(args, out files, out recursive, out outputDirectory); var compilerParameters = GetCompilerParameters(files, outputDirectory); var compiler = new SyntactikCompiler(compilerParameters); var context = compiler.Run(); if (context.Errors.Count > 0) { PrintCompilerErrors(context.Errors); } result = 0; } catch (ArgumentsParserException e) { Console.WriteLine("Fatal error: {0}", e.Message); ArgumentsParser.Help(); AppInfo2(); } catch (Exception e) { Console.WriteLine("Fatal error: {0}", e.Message); Console.WriteLine(e.StackTrace); } return(result); }