Skip to content

Commit

Permalink
(chocolatey#2983) Deprecate --remove option for apikey cmd
Browse files Browse the repository at this point in the history
We plan to replace this option with a proper `remove` subcommand in v2.0
so we are deprecating this now.
  • Loading branch information
vexx32 committed Feb 9, 2023
1 parent 7ae8339 commit 44e463f
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
;
}
Expand Down Expand Up @@ -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(@"
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 44e463f

Please sign in to comment.