/// <summary> /// Runs the compiler from the command line. /// </summary> /// <param name="arguments">The command line arguments. Each compiler defines its own.</param> /// <returns>0 for success, non-0 for error.</returns> private static async Task <int> Main(string[] arguments) { CompilerOptions options = new CompilerOptions(); ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true }); if (!parser.ParseArguments(arguments, options)) { return(1); } var tzdbCompiler = new TzdbZoneInfoCompiler(); var tzdb = await tzdbCompiler.CompileAsync(options.SourceDirectoryName !); tzdb.LogCounts(); if (options.ZoneId != null) { tzdb.GenerateDateTimeZone(options.ZoneId); return(0); } var windowsZones = LoadWindowsZones(options, tzdb.Version); if (options.WindowsOverride != null) { var overrideFile = CldrWindowsZonesParser.Parse(options.WindowsOverride); windowsZones = MergeWindowsZones(windowsZones, overrideFile); } LogWindowsZonesSummary(windowsZones); var writer = new TzdbStreamWriter(); using (var stream = CreateOutputStream(options)) { writer.Write(tzdb, windowsZones, NameIdMappingSupport.StandardNameToIdMap, stream); } if (options.OutputFileName != null) { Console.WriteLine("Reading generated data and validating..."); var source = Read(options); source.Validate(); } if (options.XmlSchema is object) { Console.WriteLine($"Writing XML schema to {options.XmlSchema}"); var source = Read(options); var provider = new DateTimeZoneCache(source); XmlSerializationSettings.DateTimeZoneProvider = provider; var settings = new XmlWriterSettings { Indent = true, NewLineChars = "\n", Encoding = new UTF8Encoding() }; using var xmlWriter = XmlWriter.Create(options.XmlSchema, settings); XmlSchemaDefinition.NodaTimeXmlSchema.Write(xmlWriter); } return(0); }
/// <summary> /// Runs the compiler from the command line. /// </summary> /// <param name="arguments">The command line arguments. Each compiler defines its own.</param> /// <returns>0 for success, non-0 for error.</returns> private static int Main(string[] arguments) { CompilerOptions options = new CompilerOptions(); ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(Console.Error) { MutuallyExclusive = true }); if (!parser.ParseArguments(arguments, options)) { return(1); } var tzdbCompiler = new TzdbZoneInfoCompiler(); var tzdb = tzdbCompiler.Compile(options.SourceDirectoryName !); tzdb.LogCounts(); if (options.ZoneId != null) { tzdb.GenerateDateTimeZone(options.ZoneId); return(0); } var windowsZones = LoadWindowsZones(options, tzdb.Version); if (options.WindowsOverride != null) { var overrideFile = CldrWindowsZonesParser.Parse(options.WindowsOverride); windowsZones = MergeWindowsZones(windowsZones, overrideFile); } LogWindowsZonesSummary(windowsZones); var writer = new TzdbStreamWriter(); using (var stream = CreateOutputStream(options)) { writer.Write(tzdb, windowsZones, NameIdMappingSupport.StandardNameToIdMap, stream); } if (options.OutputFileName != null) { Console.WriteLine("Reading generated data and validating..."); var source = Read(options); source.Validate(); } return(0); }