Пример #1
0
        /// <summary>Processes the command line arguments.</summary>
        /// <param name="args">The arguments.</param>
        /// <returns>The result.</returns>
        public int Process(string[] args)
        {
            var architecture = IntPtr.Size == 4 ? " (x86)" : " (x64)";

            _host.WriteMessage("toolchain v" + SwaggerDocument.ToolchainVersion + " (NJsonSchema v" + JsonSchema4.ToolchainVersion + ")" + architecture + "\n");
            _host.WriteMessage("Visit http://NSwag.org for more information.\n");

            var binDirectory = DynamicApis.PathGetDirectoryName(((dynamic)typeof(NSwagCommandProcessor).GetTypeInfo().Assembly).CodeBase.Replace("file:///", string.Empty));

            _host.WriteMessage("NSwag bin directory: " + binDirectory + "\n");

            if (args.Length == 0)
            {
                _host.WriteMessage("Execute the 'help' command to show a list of all the available commands.\n");
            }

            try
            {
                var processor = new CommandLineProcessor(_host);

                processor.RegisterCommandsFromAssembly(_assemblyLoaderAssembly);
                processor.RegisterCommandsFromAssembly(typeof(SwaggerToCSharpControllerCommand).GetTypeInfo().Assembly);

                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var results = processor.Process(args);
                stopwatch.Stop();

                var output   = results.Last()?.Output;
                var document = output as SwaggerDocument;
                if (document != null)
                {
                    _host.WriteMessage(document.ToJson());
                }
                else if (output != null)
                {
                    _host.WriteMessage(output.ToString());
                }

                _host.WriteMessage("\nDuration: " + stopwatch.Elapsed);
            }
            catch (Exception exception)
            {
                _host.WriteError(exception.ToString());
                return(-1);
            }

            WaitWhenDebuggerAttached();
            return(0);
        }
Пример #2
0
        /// <summary>Processes the command line arguments.</summary>
        /// <param name="args">The arguments.</param>
        /// <returns>The result.</returns>
        public int Process(string[] args)
        {
            _host.WriteMessage("toolchain v" + SwaggerDocument.ToolchainVersion +
                               " (NJsonSchema v" + JsonSchema4.ToolchainVersion + ")\n");
            _host.WriteMessage("Visit http://NSwag.org for more information.\n");

            WriteBinDirectory();

            if (args.Length == 0)
            {
                _host.WriteMessage("Execute the 'help' command to show a list of all the available commands.\n");
            }

            try
            {
                var processor = new CommandLineProcessor(_host);

                processor.RegisterCommandsFromAssembly(typeof(SwaggerToCSharpControllerCommand).GetTypeInfo().Assembly);

                var stopwatch = new Stopwatch();
                stopwatch.Start();
                processor.Process(args);
                stopwatch.Stop();

                _host.WriteMessage("\nDuration: " + stopwatch.Elapsed + "\n");
            }
            catch (Exception exception)
            {
                _host.WriteError(exception.ToString());
                return(-1);
            }

            WaitWhenDebuggerAttached();
            return(0);
        }
Пример #3
0
        static void Main(string[] args)
        {
            if (Debugger.IsAttached)
            {
                Directory.SetCurrentDirectory("C:\\Data\\Projects\\Playground");
            }

            var stopwatch = Stopwatch.StartNew();

            var assembly = Assembly.GetEntryAssembly();

            ConsoleUtilities.Write("DNT (DotNetTools, https://github.com/RSuter/DNT, v" + assembly.GetName().Version + ")\n");
            ConsoleUtilities.Write("Binary: " + assembly.Location + "\n\n");
            try
            {
                SetMsBuildExePath();

                var processor = new CommandLineProcessor(new CoreConsoleHost());
                processor.RegisterCommandsFromAssembly(typeof(CommandBase).Assembly);
                processor.Process(args);
            }
            catch (Exception e)
            {
                ConsoleUtilities.WriteError(e.ToString());
            }
            ConsoleUtilities.WriteColor("\nElapsed time: " + stopwatch.Elapsed, ConsoleColor.DarkCyan);

            if (Debugger.IsAttached)
            {
                Console.ReadLine();
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            var stopwatch = Stopwatch.StartNew();

            var assembly = Assembly.GetEntryAssembly();

            ConsoleUtilities.Write("DNT (DotNetTools, https://github.com/RSuter/DNT, v" + assembly.GetName().Version + ")\n");
            ConsoleUtilities.Write("Binary: " + assembly.Location + "\n\n");
            try
            {
                // MSBuildLocator takes care of finding the default MSBuild / Visual Studio instance
                // and setting up all necessary environment variables and paths for MSBuild.
                MSBuildLocator.RegisterDefaults();

                var processor = new CommandLineProcessor(new CoreConsoleHost());
                processor.RegisterCommandsFromAssembly(typeof(CommandBase).Assembly);
                processor.Process(args);
            }
            catch (Exception e)
            {
                ConsoleUtilities.WriteError(e.ToString());
            }
            ConsoleUtilities.WriteColor("\nElapsed time: " + stopwatch.Elapsed, ConsoleColor.DarkCyan);

            if (Debugger.IsAttached)
            {
                Console.ReadLine();
            }
        }
Пример #5
0
        /// <summary>Processes the command line arguments.</summary>
        /// <param name="args">The arguments.</param>
        /// <returns>The result.</returns>
        public int Process(string[] args)
        {
            var architecture = IntPtr.Size == 4 ? " (x86)" : " (x64)";
            _host.WriteMessage("toolchain v" + SwaggerDocument.ToolchainVersion + " (NJsonSchema v" + JsonSchema4.ToolchainVersion + ")" + architecture + "\n");
            _host.WriteMessage("Visit http://NSwag.org for more information.\n");

            var binDirectory = DynamicApis.PathGetDirectoryName(((dynamic)typeof(NSwagCommandProcessor).GetTypeInfo().Assembly).CodeBase.Replace("file:///", string.Empty));
            _host.WriteMessage("NSwag bin directory: " + binDirectory + "\n");

            if (args.Length == 0)
                _host.WriteMessage("Execute the 'help' command to show a list of all the available commands.\n");

            try
            {
                var processor = new CommandLineProcessor(_host);

                processor.RegisterCommandsFromAssembly(_assemblyLoaderAssembly);
                processor.RegisterCommandsFromAssembly(typeof(SwaggerToCSharpControllerCommand).GetTypeInfo().Assembly);

                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var results = processor.Process(args);
                stopwatch.Stop();

                var output = results.Last()?.Output;
                var document = output as SwaggerDocument;
                if (document != null)
                    _host.WriteMessage(document.ToJson());
                else if (output != null)
                    _host.WriteMessage(output.ToString());

                _host.WriteMessage("\nDuration: " + stopwatch.Elapsed);
            }
            catch (Exception exception)
            {
                _host.WriteError(exception.ToString());
                return -1;
            }

            WaitWhenDebuggerAttached();
            return 0;
        }