diff --git a/src/AWS.Deploy.CLI/Commands/CommandFactory.cs b/src/AWS.Deploy.CLI/Commands/CommandFactory.cs index 5e9925285..a13815eab 100644 --- a/src/AWS.Deploy.CLI/Commands/CommandFactory.cs +++ b/src/AWS.Deploy.CLI/Commands/CommandFactory.cs @@ -40,7 +40,7 @@ public class CommandFactory : ICommandFactory private static readonly Option _optionApplicationName = new("--application-name", "Name of the cloud application. If you choose to deploy via CloudFormation, this name will be used to identify the CloudFormation stack."); private static readonly Option _optionDiagnosticLogging = new(new[] { "-d", "--diagnostics" }, "Enable diagnostic output."); private static readonly Option _optionApply = new("--apply", "Path to the deployment settings file to be applied."); - private static readonly Option _optionDisableInteractive = new(new[] { "-s", "--silent" }, "Disable interactivity to deploy without any prompts for user input."); + private static readonly Option _optionDisableInteractive = new(new[] { "-s", "--silent" }, "Disable interactivity to execute commands without any prompts for user input."); private static readonly Option _optionOutputDirectory = new(new[] { "-o", "--output" }, "Directory path in which the CDK deployment project will be saved."); private static readonly Option _optionProjectDisplayName = new(new[] { "--project-display-name" }, "The name of the deployment project that will be displayed in the list of available deployment options."); private static readonly Option _optionDeploymentProject = new(new[] { "--deployment-project" }, "The absolute or relative path of the CDK project that will be used for deployment"); @@ -268,6 +268,7 @@ private Command BuildDeleteCommand() deleteCommand.Add(_optionRegion); deleteCommand.Add(_optionProjectPath); deleteCommand.Add(_optionDiagnosticLogging); + deleteCommand.Add(_optionDisableInteractive); deleteCommand.AddArgument(new Argument("deployment-name")); } @@ -276,6 +277,7 @@ private Command BuildDeleteCommand() try { _toolInteractiveService.Diagnostics = input.Diagnostics; + _toolInteractiveService.DisableInteractive = input.Silent; var awsCredentials = await _awsUtilities.ResolveAWSCredentials(input.Profile); var awsRegion = _awsUtilities.ResolveAWSRegion(input.Region); diff --git a/src/AWS.Deploy.CLI/Commands/CommandHandlerInput/DeleteCommandHandlerInput.cs b/src/AWS.Deploy.CLI/Commands/CommandHandlerInput/DeleteCommandHandlerInput.cs index 69e9356cb..279b688e0 100644 --- a/src/AWS.Deploy.CLI/Commands/CommandHandlerInput/DeleteCommandHandlerInput.cs +++ b/src/AWS.Deploy.CLI/Commands/CommandHandlerInput/DeleteCommandHandlerInput.cs @@ -15,5 +15,6 @@ public class DeleteCommandHandlerInput public string? ProjectPath { get; set; } public string? DeploymentName { get; set; } public bool Diagnostics { get; set; } + public bool Silent { get; set; } } } diff --git a/src/AWS.Deploy.CLI/Commands/DeleteDeploymentCommand.cs b/src/AWS.Deploy.CLI/Commands/DeleteDeploymentCommand.cs index 29bd42ad1..401def651 100644 --- a/src/AWS.Deploy.CLI/Commands/DeleteDeploymentCommand.cs +++ b/src/AWS.Deploy.CLI/Commands/DeleteDeploymentCommand.cs @@ -57,7 +57,10 @@ public async Task ExecuteAsync(string stackName) return; } - var confirmDelete = _consoleUtilities.AskYesNoQuestion($"Are you sure you want to delete {stackName}?", YesNo.No); + var confirmDelete = _interactiveService.DisableInteractive + ? YesNo.Yes + : _consoleUtilities.AskYesNoQuestion($"Are you sure you want to delete {stackName}?", YesNo.No); + if (confirmDelete == YesNo.No) { return; diff --git a/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs b/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs index b866d4e50..a128eeac5 100644 --- a/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs +++ b/test/AWS.Deploy.CLI.IntegrationTests/WebAppNoDockerFileTests.cs @@ -91,9 +91,8 @@ public async Task DefaultConfigurations() Assert.Contains(listStdOut, (deployment) => _stackName.Equals(deployment)); // Arrange input for delete - await _interactiveService.StdInWriter.WriteAsync("y"); // Confirm delete - await _interactiveService.StdInWriter.FlushAsync(); - var deleteArgs = new[] { "delete-deployment", _stackName, "--diagnostics" }; + // Use --silent flag to delete without user prompts + var deleteArgs = new[] { "delete-deployment", _stackName, "--diagnostics", "--silent" }; // Delete Assert.Equal(CommandReturnCodes.SUCCESS, await _app.Run(deleteArgs));;