diff --git a/src/Aspire.Cli/Commands/BaseCommand.cs b/src/Aspire.Cli/Commands/BaseCommand.cs index 7e54eaf7a2f..c01b6e38f97 100644 --- a/src/Aspire.Cli/Commands/BaseCommand.cs +++ b/src/Aspire.Cli/Commands/BaseCommand.cs @@ -2,9 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.CommandLine; +using System.Globalization; using Aspire.Cli.Configuration; using Aspire.Cli.Interaction; using Aspire.Cli.Projects; +using Aspire.Cli.Resources; using Aspire.Cli.Telemetry; using Aspire.Cli.Utils; @@ -103,4 +105,17 @@ internal static int HandleProjectLocatorException(ProjectLocatorException ex, II interactionService.DisplayError(errorMessage); return exitCode; } + + internal static void AddNonInteractiveRequiresYesValidator(Command command, Option yesOption) + { + command.Validators.Add(result => + { + var nonInteractive = result.GetValue(RootCommand.NonInteractiveOption); + var yes = result.GetValue(yesOption); + if (nonInteractive && !yes) + { + result.AddError(string.Format(CultureInfo.CurrentCulture, SharedCommandStrings.NonInteractiveRequiresYesFormat, command.Name)); + } + }); + } } diff --git a/src/Aspire.Cli/Commands/DestroyCommand.cs b/src/Aspire.Cli/Commands/DestroyCommand.cs index 60da518efaf..6ef723c2739 100644 --- a/src/Aspire.Cli/Commands/DestroyCommand.cs +++ b/src/Aspire.Cli/Commands/DestroyCommand.cs @@ -30,15 +30,7 @@ public DestroyCommand(IDotNetCliRunner runner, IInteractionService interactionSe }; Options.Add(_yesOption); - Validators.Add(result => - { - var nonInteractive = result.GetValue(RootCommand.NonInteractiveOption); - var yes = result.GetValue(_yesOption); - if (nonInteractive && !yes) - { - result.AddError(DestroyCommandStrings.NonInteractiveRequiresYes); - } - }); + AddNonInteractiveRequiresYesValidator(this, _yesOption); } protected override string OperationCompletedPrefix => DestroyCommandStrings.OperationCompletedPrefix; diff --git a/src/Aspire.Cli/Commands/UpdateCommand.cs b/src/Aspire.Cli/Commands/UpdateCommand.cs index e815a74d6f1..6ac8fe67617 100644 --- a/src/Aspire.Cli/Commands/UpdateCommand.cs +++ b/src/Aspire.Cli/Commands/UpdateCommand.cs @@ -80,6 +80,8 @@ public UpdateCommand( Options.Add(s_yesOption); Options.Add(s_nugetConfigDirOption); + AddNonInteractiveRequiresYesValidator(this, s_yesOption); + // Customize description based on whether staging channel is enabled var isStagingEnabled = KnownFeatures.IsStagingChannelEnabled(_features, _configuration); @@ -222,7 +224,10 @@ protected override async Task ExecuteAsync(ParseResult parseResult, Cancell } // Update packages using the appropriate project handler - var confirmBinding = PromptBinding.CreateWithInteractiveDefault(parseResult, s_yesOption, true); + // The validator ensures --yes is required when --non-interactive is specified, + // so by this point --yes is always explicitly provided in non-interactive mode. + // defaultValue: true means the interactive prompt defaults to "yes" (accept). + var confirmBinding = PromptBinding.Create(parseResult, s_yesOption, defaultValue: true); var nugetConfigDirBinding = PromptBinding.Create(parseResult, s_nugetConfigDirOption); var updateContext = new UpdatePackagesContext { diff --git a/src/Aspire.Cli/Interaction/PromptBinding.cs b/src/Aspire.Cli/Interaction/PromptBinding.cs index 6f706270e6f..68817dd3f6c 100644 --- a/src/Aspire.Cli/Interaction/PromptBinding.cs +++ b/src/Aspire.Cli/Interaction/PromptBinding.cs @@ -108,13 +108,6 @@ public static PromptBinding Create(ParseResult parseResult, Option opti public static PromptBinding Create(ParseResult parseResult, Option option, T defaultValue) => new(parseResult, FormatOptionName(option), BuildOptionResolver(option), defaultValue, hasExplicitDefault: true); - /// - /// Creates a that uses as the - /// default for interactive prompts but still requires the CLI option in non-interactive mode. - /// - public static PromptBinding CreateWithInteractiveDefault(ParseResult parseResult, Option option, T interactiveDefault) => - new(parseResult, FormatOptionName(option), BuildOptionResolver(option), interactiveDefault, hasExplicitDefault: false); - /// /// Creates a with only a default value and no CLI symbol binding. /// Use when there is no corresponding CLI option or argument for the prompt. diff --git a/src/Aspire.Cli/Resources/DestroyCommandStrings.Designer.cs b/src/Aspire.Cli/Resources/DestroyCommandStrings.Designer.cs index 5c2af895f41..2d8ae6319d4 100644 --- a/src/Aspire.Cli/Resources/DestroyCommandStrings.Designer.cs +++ b/src/Aspire.Cli/Resources/DestroyCommandStrings.Designer.cs @@ -77,15 +77,6 @@ public static string Description { return ResourceManager.GetString("Description", resourceCulture); } } - - /// - /// Looks up a localized string similar to The destroy command requires --yes when the --non-interactive option is specified.. - /// - public static string NonInteractiveRequiresYes { - get { - return ResourceManager.GetString("NonInteractiveRequiresYes", resourceCulture); - } - } /// /// Looks up a localized string similar to The output path containing the deployment artifacts to destroy. diff --git a/src/Aspire.Cli/Resources/DestroyCommandStrings.resx b/src/Aspire.Cli/Resources/DestroyCommandStrings.resx index bee9ab48370..c98f9d4bbbe 100644 --- a/src/Aspire.Cli/Resources/DestroyCommandStrings.resx +++ b/src/Aspire.Cli/Resources/DestroyCommandStrings.resx @@ -120,9 +120,6 @@ Destroy a previously deployed AppHost environment (Preview) - - The destroy command requires --yes when the --non-interactive option is specified. - The output path containing the deployment artifacts to destroy diff --git a/src/Aspire.Cli/Resources/SharedCommandStrings.Designer.cs b/src/Aspire.Cli/Resources/SharedCommandStrings.Designer.cs index afb05bc7640..fa810c28a8c 100644 --- a/src/Aspire.Cli/Resources/SharedCommandStrings.Designer.cs +++ b/src/Aspire.Cli/Resources/SharedCommandStrings.Designer.cs @@ -146,5 +146,11 @@ internal static string PipelineStepsSummaryTitle { return ResourceManager.GetString("PipelineStepsSummaryTitle", resourceCulture); } } + + internal static string NonInteractiveRequiresYesFormat { + get { + return ResourceManager.GetString("NonInteractiveRequiresYesFormat", resourceCulture); + } + } } } diff --git a/src/Aspire.Cli/Resources/SharedCommandStrings.resx b/src/Aspire.Cli/Resources/SharedCommandStrings.resx index 54a95f9e84c..eee6642996a 100644 --- a/src/Aspire.Cli/Resources/SharedCommandStrings.resx +++ b/src/Aspire.Cli/Resources/SharedCommandStrings.resx @@ -169,4 +169,8 @@ Steps Summary: + + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.cs.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.cs.xlf index df10f4b3f19..9b1b2aaf2c1 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.cs.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.cs.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.de.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.de.xlf index ccb65be3651..90aec8b6558 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.de.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.de.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.es.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.es.xlf index 14c8a539caf..cbfac6dbc82 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.es.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.es.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.fr.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.fr.xlf index 4bb3522c84a..beb5d05a030 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.fr.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.fr.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.it.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.it.xlf index 698a37bae1f..c3401bc54d4 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.it.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.it.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ja.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ja.xlf index 1d8a89de91d..69f47e07da9 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ja.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ja.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ko.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ko.xlf index 7c64596959e..9693e4695e9 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ko.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ko.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pl.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pl.xlf index 5d9ab5de0de..8b95acaff7e 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pl.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pl.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pt-BR.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pt-BR.xlf index 8945e26a909..2fd39a6800d 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pt-BR.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.pt-BR.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ru.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ru.xlf index d19e2575d55..3fe68554b97 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ru.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.ru.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.tr.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.tr.xlf index 0bd08dffe4f..68a10828607 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.tr.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.tr.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hans.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hans.xlf index 372bdb4b285..dbc09d2bc57 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hans.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hans.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hant.xlf b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hant.xlf index 6757c480f1d..c04c4da55a9 100644 --- a/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hant.xlf +++ b/src/Aspire.Cli/Resources/xlf/DestroyCommandStrings.zh-Hant.xlf @@ -12,11 +12,6 @@ The destroy operation was canceled. - - The destroy command requires --yes when the --non-interactive option is specified. - The destroy command requires --yes when the --non-interactive option is specified. - - Destroy completed Destroy completed diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.cs.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.cs.xlf index 5b6f5ca0ac3..975457fb3b9 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.cs.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.cs.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.de.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.de.xlf index 10f8ff925a5..ac974fc5a43 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.de.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.de.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.es.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.es.xlf index 58311911980..2327d8b8fce 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.es.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.es.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.fr.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.fr.xlf index 2b728b4e22c..a234f38fd58 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.fr.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.fr.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.it.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.it.xlf index aa928d48b3b..b4d1855d2ce 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.it.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.it.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ja.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ja.xlf index 180dc8699be..046dccf648a 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ja.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ja.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ko.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ko.xlf index 7329b3e5dd4..32a8b3389f6 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ko.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ko.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pl.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pl.xlf index b54c6cc3418..e601ceea411 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pl.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pl.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pt-BR.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pt-BR.xlf index 88e0d26cb38..18509019850 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pt-BR.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.pt-BR.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ru.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ru.xlf index 89dfe72a9e3..9cc548b801b 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ru.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.ru.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.tr.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.tr.xlf index 022fa095900..de041342297 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.tr.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.tr.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hans.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hans.xlf index b81bf4ff2d1..1d4df3923b6 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hans.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hans.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hant.xlf b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hant.xlf index abc7c7961ea..8701410c11c 100644 --- a/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hant.xlf +++ b/src/Aspire.Cli/Resources/xlf/SharedCommandStrings.zh-Hant.xlf @@ -42,6 +42,11 @@ The path to the Aspire AppHost project file or a directory to search + + The {0} command requires --yes when the --non-interactive option is specified. + The {0} command requires --yes when the --non-interactive option is specified. + {0} is the command name. + The environment to use for the operation. The default is 'Production'. The environment to use for the operation. The default is 'Production'. diff --git a/tests/Aspire.Cli.Tests/Commands/DestroyCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/DestroyCommandTests.cs index 327e9697678..560e046a9d5 100644 --- a/tests/Aspire.Cli.Tests/Commands/DestroyCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/DestroyCommandTests.cs @@ -153,7 +153,8 @@ public async Task DestroyCommandFailsFastWhenNonInteractiveWithoutYes(string com var exitCode = await result.InvokeAsync().DefaultTimeout(); Assert.Equal(ExitCodeConstants.InvalidCommand, exitCode); - Assert.Contains(result.Errors, error => string.Equals(error.Message, DestroyCommandStrings.NonInteractiveRequiresYes, StringComparison.Ordinal)); + var error = Assert.Single(result.Errors); + Assert.Equal(string.Format(System.Globalization.CultureInfo.CurrentCulture, SharedCommandStrings.NonInteractiveRequiresYesFormat, "destroy"), error.Message); Assert.False(appHostStarted); } diff --git a/tests/Aspire.Cli.Tests/Commands/UpdateCommandTests.cs b/tests/Aspire.Cli.Tests/Commands/UpdateCommandTests.cs index 3c562b060e9..c70f625abc2 100644 --- a/tests/Aspire.Cli.Tests/Commands/UpdateCommandTests.cs +++ b/tests/Aspire.Cli.Tests/Commands/UpdateCommandTests.cs @@ -36,6 +36,25 @@ public async Task UpdateCommandWithHelpArgumentReturnsZero() Assert.Equal(ExitCodeConstants.Success, exitCode); } + [Theory] + [InlineData("update --non-interactive")] + [InlineData("--non-interactive update")] + public async Task UpdateCommandFailsFastWhenNonInteractiveWithoutYes(string commandLine) + { + using var workspace = TemporaryWorkspace.Create(outputHelper); + + var services = CliTestHelper.CreateServiceCollection(workspace, outputHelper); + using var provider = services.BuildServiceProvider(); + var command = provider.GetRequiredService(); + + var result = command.Parse(commandLine); + var exitCode = await result.InvokeAsync().DefaultTimeout(); + + Assert.Equal(ExitCodeConstants.InvalidCommand, exitCode); + var error = Assert.Single(result.Errors); + Assert.Equal(string.Format(System.Globalization.CultureInfo.CurrentCulture, SharedCommandStrings.NonInteractiveRequiresYesFormat, "update"), error.Message); + } + [Fact] public async Task UpdateCommand_WhenProjectOptionSpecified_PassesProjectFileToProjectLocator() {