Ejemplo n.º 1
0
        /// <summary>
        /// The main entry point.
        /// </summary>
        /// <param name="args">The console arguments.</param>
        /// <returns>A statuc code.</returns>
        public static async Task <int> Main(string[] args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            Logger.Default = new ColoredConsoleLogger(nameof(CodeGenConsole));

            // Check for special case / internal use arguments.
            if (args.Length == 1)
            {
                switch (args[0].ToUpperInvariant())
                {
                case "--GENERATEENTITYXMLSCHEMA": return(SpecialActivitiesCenter("Generate Entity XML Schema", "./Schema/codegen.entity.xsd", fn => XmlSchemaGenerator.Create <Config.Entity.CodeGenConfig>(ConfigType.Entity).Save(fn, System.Xml.Linq.SaveOptions.None)));

                case "--GENERATEENTITYJSONSCHEMA": return(SpecialActivitiesCenter("Generate Entity JSON Schema", "./Schema/entity.beef.json", fn => File.WriteAllText(fn, JsonSchemaGenerator.Create <Config.Entity.CodeGenConfig>("JSON Schema for Beef Entity code-generation (https://github.com/Avanade/Beef)."))));

                case "--GENERATEDATABASEXMLSCHEMA": return(SpecialActivitiesCenter("Generate Database XML Schema", "./Schema/codegen.table.xsd", fn => XmlSchemaGenerator.Create <Config.Database.CodeGenConfig>(ConfigType.Database).Save(fn, System.Xml.Linq.SaveOptions.None)));

                case "--GENERATEDATABASEJSONSCHEMA": return(SpecialActivitiesCenter("Generate Database JSON Schema", "./Schema/database.beef.json", fn => File.WriteAllText(fn, JsonSchemaGenerator.Create <Config.Database.CodeGenConfig>("JSON Schema for Beef Database code-generation (https://github.com/Avanade/Beef)."))));

                case "--GENERATEENTITYMARKDOWN": return(SpecialActivitiesCenter("Generate Entity YAML documentation markdown file(s)", "../../docs/", fn => SchemaMarkdownGenerator.Create <Config.Entity.CodeGenConfig>(fn, ConfigType.Entity, true)));

                case "--GENERATEENTITYXMLMARKDOWN": return(SpecialActivitiesCenter("Generate Entity XML documentation markdown file(s)", "../../docs/", fn => SchemaMarkdownGenerator.Create <Config.Entity.CodeGenConfig>(fn, ConfigType.Entity, false)));

                case "--GENERATEDATABASEMARKDOWN": return(SpecialActivitiesCenter("Generate Database YAML documentation markdown file(s)", "../../docs/", fn => SchemaMarkdownGenerator.Create <Config.Database.CodeGenConfig>(fn, ConfigType.Database, true)));

                case "--GENERATEDATABASEXMLMARKDOWN": return(SpecialActivitiesCenter("Generate Database XML documentation markdown file(s)", "../../docs/", fn => SchemaMarkdownGenerator.Create <Config.Database.CodeGenConfig>(fn, ConfigType.Database, false)));
                }
            }

            return(await CodeGenConsole.Create().RunAsync(args).ConfigureAwait(false));
        }