From 44e463f2ba14b19ef76ab31cc1ea0cc8206599e1 Mon Sep 17 00:00:00 2001 From: Rain Sallow Date: Thu, 9 Feb 2023 15:52:49 -0500 Subject: [PATCH] (#2983) Deprecate `--remove` option for apikey cmd We plan to replace this option with a proper `remove` subcommand in v2.0 so we are deprecating this now. --- .../commands/ChocolateyApiKeyCommand.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyApiKeyCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyApiKeyCommand.cs index 85742f60ee..d2e29a34e1 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyApiKeyCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyApiKeyCommand.cs @@ -32,6 +32,11 @@ public class ChocolateyApiKeyCommand : ICommand { private readonly IChocolateyConfigSettingsService _configSettingsService; + private const string RemoveOptionDeprecationMessage = @" +The --rem / --remove option is deprecated and will be removed in v2.0.0. +In future versions, this option will be replaced with the `remove` subcommand. +"; + public ChocolateyApiKeyCommand(IChocolateyConfigSettingsService configSettingsService) { _configSettingsService = configSettingsService; @@ -49,7 +54,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon "ApiKey - The API key for the source. This is the authentication that identifies you and allows you to push to a source. With some sources this is either a key or it could be a user name and password specified as 'user:password'.", option => configuration.ApiKeyCommand.Key = option.remove_surrounding_quotes()) .Add("rem|remove", - "Removes an API key from Chocolatey", + "Removes an API key from Chocolatey (DEPRECATED)", option => configuration.ApiKeyCommand.Remove = true) ; } @@ -82,6 +87,8 @@ source so it doesn't need to be specified every time. Anything that doesn't contain source and key will list api keys. "); + this.Log().Warn(ChocolateyLoggers.Important, "DEPRECATION NOTICE"); + this.Log().Warn(RemoveOptionDeprecationMessage); "chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage"); "chocolatey".Log().Info(@" @@ -152,6 +159,8 @@ public virtual void run(ChocolateyConfiguration configuration) { if (configuration.ApiKeyCommand.Remove) { + this.Log().Warn(ChocolateyLoggers.Important, "DEPRECATION NOTICE"); + this.Log().Warn(RemoveOptionDeprecationMessage); _configSettingsService.remove_api_key(configuration); } else if (string.IsNullOrWhiteSpace(configuration.ApiKeyCommand.Key))