Exemplo n.º 1
0
        public static Command CreateDeployCommand()
        {
            var command = new Command("deploy", "deploy the application")
            {
                CommonArguments.Path_Required,
                StandardOptions.Interactive,
                StandardOptions.Verbosity,
                StandardOptions.Namespace,
                StandardOptions.Framework,
                StandardOptions.Tags,
                StandardOptions.CreateForce("Override validation and force deployment.")
            };

            command.Handler = CommandHandler.Create <DeployCommandArguments>(async args =>
            {
                // Workaround for https://github.com/dotnet/command-line-api/issues/723#issuecomment-593062654
                if (args.Path is null)
                {
                    throw new CommandException("No project or solution file was found.");
                }

                var output = new OutputContext(args.Console, args.Verbosity);
                output.WriteInfoLine("Loading Application Details...");

                var filter = ApplicationFactoryFilter.GetApplicationFactoryFilter(args.Tags);

                var application = await ApplicationFactory.CreateAsync(output, args.Path, args.Framework, filter);
                if (application.Services.Count == 0)
                {
                    throw new CommandException($"No services found in \"{application.Source.Name}\"");
                }

                if (!string.IsNullOrEmpty(args.Namespace))
                {
                    application.Namespace = args.Namespace;
                }

                var executeOutput = new OutputContext(args.Console, args.Verbosity);
                await ExecuteDeployAsync(executeOutput, application, environment: "production", args.Interactive, args.Force);
            });

            return(command);
        }
Exemplo n.º 2
0
        private static Command CreateInitCommand()
        {
            var command = new Command("init", "create a yaml manifest")
            {
                CommonArguments.Path_Optional,
                StandardOptions.CreateForce("Overrides the tye.yaml file if already present for project.")
            };

            command.Handler = CommandHandler.Create <InitCommandArguments>(args =>
            {
                var watch = System.Diagnostics.Stopwatch.StartNew();

                var output         = new OutputContext(args.Console, args.Verbosity);
                var outputFilePath = InitHost.CreateTyeFile(args.Path, args.Force);
                output.WriteInfoLine($"Created '{outputFilePath}'.");

                watch.Stop();
                var elapsedTime = watch.Elapsed;
                output.WriteInfoLine($"Time Elapsed: {elapsedTime.Hours:00}:{elapsedTime.Minutes:00}:{elapsedTime.Seconds:00}:{elapsedTime.Milliseconds / 10:00}");
            });

            return(command);
        }