public DwcaCodegenCommand() : base("#!dwca-codegen", "Generate strongly typed class files for Darwin Core Archive") { AddArgument(new Argument <string>() { Name = "archivePath", Description = "Path to archive folder or zip file" }); AddOption(new Option <string>( aliases: new[] { "-c", "--configName" }, description: "Name of configuration variable", getDefaultValue: () => "" )); Handler = CommandHandler.Create <KernelInvocationContext, string, string>((Func <KernelInvocationContext, string, string, Task>)(async(context, archivePath, configName) => { var archive = new ArchiveReader(archivePath); var csharpKernel = (ISupportGetValue)context.HandlingKernel.FindKernel("csharp"); if (!csharpKernel.TryGetValue <IGeneratorConfiguration>(configName, out IGeneratorConfiguration config)) { config = new GeneratorConfigurationBuilder().Build(); } context.Display($"Opening archive {archive.FileName} using configuration", new[] { "text/html" }); context.Display(config, new[] { "text/html" }); await GenerateClass(context, archive.CoreFile, config); foreach (var extension in archive.Extensions.GetFileReaders()) { await GenerateClass(context, extension, config); } })); }
public void ShouldFormatHeader() { var config = new GeneratorConfigurationBuilder() .AddProperty(Terms.decimalLatitude, "double", true, "Latitude") .Build(); using var tw = new StringWriter(); GeneratorConfigFormatter.Register(config, tw); var html = tw.ToString(); Assert.NotNull(html); }