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.TrashLib/Services/CustomFormat/Guide/CustomFormatDataLister.cs

42 lines
1.2 KiB

using Recyclarr.TrashLib.Config;
using Spectre.Console;
namespace Recyclarr.TrashLib.Services.CustomFormat.Guide;
public class CustomFormatDataLister
{
private readonly IAnsiConsole _console;
private readonly ICustomFormatGuideService _guide;
public CustomFormatDataLister(IAnsiConsole console, ICustomFormatGuideService guide)
{
_console = console;
_guide = guide;
}
public void ListCustomFormats(SupportedServices serviceType)
{
_console.WriteLine("\nList of Custom Formats in the TRaSH Guides:");
var categories = _guide.GetCustomFormatData(serviceType)
.OrderBy(x => x.Name)
.ToLookup(x => x.Category)
.OrderBy(x => x.Key);
foreach (var cat in categories)
{
var title = cat.Key is not null ? $"{cat.Key}" : "[No Category]";
_console.WriteLine($"\n # {title}");
foreach (var cf in cat)
{
_console.WriteLine($" - {cf.TrashId} # {cf.Name}");
}
}
_console.WriteLine(
"\nThe above Custom Formats are in YAML format and ready to be copied & pasted " +
"under the `trash_ids:` property.");
}
}