BaseCacheCommand.cs•952 B
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Diagnostics.CodeAnalysis;
using AzureMcp.Core.Commands;
using AzureMcp.Core.Commands.Subscription;
using AzureMcp.Redis.Options.CacheForRedis;
namespace AzureMcp.Redis.Commands.CacheForRedis;
public abstract class BaseCacheCommand<
    [DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] T>
    : SubscriptionCommand<T> where T : BaseCacheOptions, new()
{
    protected readonly Option<string> _cacheOption = RedisOptionDefinitions.Cache;
    protected override void RegisterOptions(Command command)
    {
        base.RegisterOptions(command);
        command.AddOption(_cacheOption);
        RequireResourceGroup();
    }
    protected override T BindOptions(ParseResult parseResult)
    {
        var options = base.BindOptions(parseResult);
        options.Cache = parseResult.GetValueForOption(_cacheOption);
        return options;
    }
}