Example #1
0
        public static Command CreateGenerateCommand()
        {
            var command = new Command("generate", "generate kubernetes manifests")
            {
                CommonArguments.Path_Required,
                StandardOptions.Interactive,
                StandardOptions.Verbosity,
                StandardOptions.Namespace,
            };

            // This is a super-secret VIP-only command! It's useful for testing, but we're
            // not documenting it right now.
            command.IsHidden = true;

            command.Handler = CommandHandler.Create <IConsole, FileInfo, Verbosity, bool, string>((console, path, verbosity, interactive, @namespace) =>
            {
                // Workaround for https://github.com/dotnet/command-line-api/issues/723#issuecomment-593062654
                if (path is null)
                {
                    throw new CommandException("No project or solution file was found.");
                }

                return(GenerateHost.GenerateAsync(console, path, verbosity, interactive, @namespace));
            });

            return(command);
        }
Example #2
0
        public static Command CreateGenerateCommand()
        {
            var command = new Command("generate", "generate kubernetes manifests")
            {
                CommonArguments.Path_Required,
                StandardOptions.Interactive,
                StandardOptions.Verbosity,
                StandardOptions.Namespace,
                StandardOptions.Tags,
                StandardOptions.Framework,
            };

            // This is a super-secret VIP-only command! It's useful for testing, but we're
            // not documenting it right now.
            command.IsHidden = true;

            command.Handler = CommandHandler.Create <GenerateCommandArguments>(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);

                return(GenerateHost.GenerateAsync(output, args.Path, args.Interactive, args.Namespace, args.Framework, filter));
            });

            return(command);
        }