Files
Umbraco-CMS/src/JsonSchema/Program.cs

50 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Xml.Schema;
using CommandLine;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using NJsonSchema;
using NJsonSchema.Generation;
namespace JsonSchema
{
class Program
{
public class Options
{
[Option('o', "outputFile", Required = false, HelpText = "Set path of the output file.", Default = "../../../../Umbraco.Web.UI.NetCore/umbraco/config/appsettings-schema.json")]
public string OutputFile { get; set; }
}
static async Task Main(string[] args)
{
2021-06-24 13:24:57 +02:00
try
{
Parser.Default.ParseArguments<Options>(args)
.WithParsedAsync<Options>(Execute);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
private static async Task Execute(Options options)
{
2021-06-24 13:24:57 +02:00
var generator = new UmbracoJsonSchemaGenerator();
var schema = await generator.Generate();
var path = Path.Combine(Environment.CurrentDirectory, options.OutputFile);
2021-06-24 13:24:57 +02:00
await File.WriteAllTextAsync(path, schema);
Console.WriteLine("File written at " + path);
}
}
}