コード例 #1
0
ファイル: Program.cs プロジェクト: chenkaibin/NSwag
        static void Main(string[] args)
        {
            var host = new ConsoleHost();
            host.WriteMessage("NSwag command line: v" + typeof(SwaggerInfo).Assembly.GetName().Version + "\n");
            host.WriteMessage("Visit http://NSwag.org for more information.");
            host.WriteMessage("\n");

            try
            {
                var processor = new CommandLineProcessor(host);

                processor.RegisterCommand<CSharpCommand>("csharp");
                processor.RegisterCommand<TypeScriptCommand>("typescript");

                processor.Process(args);
            }
            catch (Exception exception)
            {
                var savedForegroundColor = System.Console.ForegroundColor;
                System.Console.ForegroundColor = ConsoleColor.Red;
                host.WriteMessage(exception.ToString());
                System.Console.ForegroundColor = savedForegroundColor;
            }

            if (Debugger.IsAttached)
                System.Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: MarkWalls/NSwag
        static void Main(string[] args)
        {
            var host = new ConsoleHost();
            host.WriteMessage("NSwag command line: v" + typeof(SwaggerInfo).Assembly.GetName().Version + "\n");
            host.WriteMessage("Visit http://NSwag.org for more information.\n");
            host.WriteMessage("Execute the 'help' command to show a list of all the available commands.\n");

            try
            {
                var processor = new CommandLineProcessor(host);

                processor.RegisterCommand<WebApiToSwaggerCommand>("webapi2swagger");

                processor.RegisterCommand<JsonSchemaToCSharpCommand>("jsonschema2csharp");
                processor.RegisterCommand<JsonSchemaToTypeScriptCommand>("jsonschema2typescript");
                
                processor.RegisterCommand<SwaggerToCSharpCommand>("swagger2csharp");
                processor.RegisterCommand<SwaggerToTypeScriptCommand>("swagger2typescript");

                processor.Process(args);
            }
            catch (Exception exception)
            {
                var savedForegroundColor = Console.ForegroundColor; 
                Console.ForegroundColor = ConsoleColor.Red;
                host.WriteMessage(exception.ToString());
                Console.ForegroundColor = savedForegroundColor;
            }

            if (Debugger.IsAttached)
            {
                Console.WriteLine("Press <any> key to exit...");
                Console.ReadKey();
            }
        }