From 227e4e82e5419b9072152b8349690388f0f6137d Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Wed, 24 Aug 2022 19:36:53 -0500 Subject: [PATCH] feat(radarr): New --list-qualities argument For listing quality definition types in the guide. --- CHANGELOG.md | 4 ++++ src/Recyclarr/Command/RadarrCommand.cs | 12 +++++++++++- ...terTest.cs => RadarrGuideDataListerTest.cs} | 4 ++-- ...rmatLister.cs => IRadarrGuideDataLister.cs} | 3 ++- ...ormatLister.cs => RadarrGuideDataLister.cs} | 18 ++++++++++++++++-- .../Services/Radarr/RadarrAutofacModule.cs | 2 +- 6 files changed, 36 insertions(+), 7 deletions(-) rename src/TrashLib.Tests/Radarr/CustomFormat/{CustomFormatListerTest.cs => RadarrGuideDataListerTest.cs} (92%) rename src/TrashLib/Services/Radarr/CustomFormat/{ICustomFormatLister.cs => IRadarrGuideDataLister.cs} (56%) rename src/TrashLib/Services/Radarr/CustomFormat/{CustomFormatLister.cs => RadarrGuideDataLister.cs} (58%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aeb0044..9cfc6d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Radarr: New `--list-qualities` argument to get a list of quality definition types from the guide. + ### Changed - Quality definition data is now pulled from JSON files. diff --git a/src/Recyclarr/Command/RadarrCommand.cs b/src/Recyclarr/Command/RadarrCommand.cs index 3b7f0dd7..ac23db89 100644 --- a/src/Recyclarr/Command/RadarrCommand.cs +++ b/src/Recyclarr/Command/RadarrCommand.cs @@ -17,13 +17,17 @@ internal class RadarrCommand : ServiceCommand "List available custom formats from the guide in YAML format.")] public bool ListCustomFormats { get; [UsedImplicitly] set; } + [CommandOption("list-qualities", Description = + "List available quality definition types from the guide.")] + public bool ListQualities { get; [UsedImplicitly] set; } + public override string Name => "Radarr"; public override async Task Process(IServiceLocatorProxy container) { await base.Process(container); - var lister = container.Resolve(); + var lister = container.Resolve(); var log = container.Resolve(); var customFormatUpdaterFactory = container.Resolve>(); var qualityUpdaterFactory = container.Resolve>(); @@ -35,6 +39,12 @@ internal class RadarrCommand : ServiceCommand return; } + if (ListQualities) + { + lister.ListQualities(); + return; + } + foreach (var config in configLoader.LoadMany(Config, "radarr")) { log.Information("Processing server {Url}", FlurlLogging.SanitizeUrl(config.BaseUrl)); diff --git a/src/TrashLib.Tests/Radarr/CustomFormat/CustomFormatListerTest.cs b/src/TrashLib.Tests/Radarr/CustomFormat/RadarrGuideDataListerTest.cs similarity index 92% rename from src/TrashLib.Tests/Radarr/CustomFormat/CustomFormatListerTest.cs rename to src/TrashLib.Tests/Radarr/CustomFormat/RadarrGuideDataListerTest.cs index dc00f67f..c8081670 100644 --- a/src/TrashLib.Tests/Radarr/CustomFormat/CustomFormatListerTest.cs +++ b/src/TrashLib.Tests/Radarr/CustomFormat/RadarrGuideDataListerTest.cs @@ -12,13 +12,13 @@ namespace TrashLib.Tests.Radarr.CustomFormat; [TestFixture] [Parallelizable(ParallelScope.All)] -public class CustomFormatListerTest +public class RadarrGuideDataListerTest { [Test, AutoMockData] public void Custom_formats_appear_in_console_output( [Frozen] IRadarrGuideService guide, [Frozen(Matching.ImplementedInterfaces)] FakeInMemoryConsole console, - CustomFormatLister sut) + RadarrGuideDataLister sut) { var testData = new[] { diff --git a/src/TrashLib/Services/Radarr/CustomFormat/ICustomFormatLister.cs b/src/TrashLib/Services/Radarr/CustomFormat/IRadarrGuideDataLister.cs similarity index 56% rename from src/TrashLib/Services/Radarr/CustomFormat/ICustomFormatLister.cs rename to src/TrashLib/Services/Radarr/CustomFormat/IRadarrGuideDataLister.cs index e1e8f76c..8262c7a7 100644 --- a/src/TrashLib/Services/Radarr/CustomFormat/ICustomFormatLister.cs +++ b/src/TrashLib/Services/Radarr/CustomFormat/IRadarrGuideDataLister.cs @@ -1,6 +1,7 @@ namespace TrashLib.Services.Radarr.CustomFormat; -public interface ICustomFormatLister +public interface IRadarrGuideDataLister { void ListCustomFormats(); + void ListQualities(); } diff --git a/src/TrashLib/Services/Radarr/CustomFormat/CustomFormatLister.cs b/src/TrashLib/Services/Radarr/CustomFormat/RadarrGuideDataLister.cs similarity index 58% rename from src/TrashLib/Services/Radarr/CustomFormat/CustomFormatLister.cs rename to src/TrashLib/Services/Radarr/CustomFormat/RadarrGuideDataLister.cs index a4ec64a9..43fb3408 100644 --- a/src/TrashLib/Services/Radarr/CustomFormat/CustomFormatLister.cs +++ b/src/TrashLib/Services/Radarr/CustomFormat/RadarrGuideDataLister.cs @@ -1,16 +1,17 @@ using CliFx.Infrastructure; using JetBrains.Annotations; +using MoreLinq; using TrashLib.Services.Radarr.CustomFormat.Guide; namespace TrashLib.Services.Radarr.CustomFormat; [UsedImplicitly] -public class CustomFormatLister : ICustomFormatLister +public class RadarrGuideDataLister : IRadarrGuideDataLister { private readonly IConsole _console; private readonly IRadarrGuideService _guide; - public CustomFormatLister(IConsole console, IRadarrGuideService guide) + public RadarrGuideDataLister(IConsole console, IRadarrGuideService guide) { _console = console; _guide = guide; @@ -30,4 +31,17 @@ public class CustomFormatLister : ICustomFormatLister "\nThe above Custom Formats are in YAML format and ready to be copied & pasted " + "under the `trash_ids:` property."); } + + public void ListQualities() + { + _console.Output.WriteLine("\nList of Quality Definition types in the TRaSH Guides:\n"); + + _guide.GetQualities() + .Select(x => x.Type) + .ForEach(x => _console.Output.WriteLine($" - {x}")); + + _console.Output.WriteLine( + "\nThe above quality definition types can be used with the `quality_definition:` property in your " + + "recyclarr.yml file."); + } } diff --git a/src/TrashLib/Services/Radarr/RadarrAutofacModule.cs b/src/TrashLib/Services/Radarr/RadarrAutofacModule.cs index 5de66bcd..8e429c38 100644 --- a/src/TrashLib/Services/Radarr/RadarrAutofacModule.cs +++ b/src/TrashLib/Services/Radarr/RadarrAutofacModule.cs @@ -33,7 +33,7 @@ public class RadarrAutofacModule : Module builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); - builder.RegisterType().As(); + builder.RegisterType().As(); // Guide Processor