You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
recyclarr/src/Recyclarr.Cli/Processors/ConfigListProcessor.cs

39 lines
1.1 KiB

using Autofac.Features.Indexed;
using Recyclarr.TrashLib.Config.Listers;
using Recyclarr.TrashLib.Repo;
namespace Recyclarr.Cli.Processors;
public class ConfigListProcessor
{
private readonly ILogger _log;
private readonly IIndex<ConfigListCategory, IConfigLister> _configListers;
private readonly IConfigTemplatesRepo _repo;
public ConfigListProcessor(
ILogger log,
IIndex<ConfigListCategory, IConfigLister> configListers,
IConfigTemplatesRepo repo)
{
_log = log;
_configListers = configListers;
_repo = repo;
}
public async Task Process(ConfigListCategory listCategory)
{
if (listCategory == ConfigListCategory.Templates)
{
await _repo.Update();
}
_log.Debug("Listing configuration for category {Category}", listCategory);
if (!_configListers.TryGetValue(listCategory, out var lister))
{
throw new ArgumentOutOfRangeException(nameof(listCategory), listCategory, "Unknown list category");
}
await lister.List();
}
}