Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var options = new Options();

            if (!Parser.Default.ParseArgumentsStrict(args, options))
            {
                return;
            }

            Generator generator;

            switch (options.Type)
            {
            case GeneratorType.MarkDown:
                generator = new MarkdownGenerator(options.Output);
                break;

            case GeneratorType.CSharp:
                if (options.ConfigurationFile == null)
                {
                    Console.Error.WriteLine("ERROR: When type is CSharp, a configuration file is required.");
                    Console.Error.WriteLine(options.Usage());
                    return;
                }

                generator = new CSharpGenerator(options.Output, options.ConfigurationFile);
                break;

            case GeneratorType.Validation:
                generator = new ValidationDocumentGenerator(options.Output);
                break;

            default:
                return;
            }

            // Load the schema
            var    schemaLoader = new SchemaLoader(Path.GetDirectoryName(options.PacketSchema));
            Schema packetSchema = schemaLoader.Load(options.PacketSchema);

            // Generate output from the schema.
            generator.Generate(packetSchema);
        }