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/Pipelines/QualityProfile/PipelinePhases/QualityProfilePreviewPhase.cs

58 lines
1.7 KiB

using Spectre.Console;
namespace Recyclarr.Cli.Pipelines.QualityProfile.PipelinePhases;
public class QualityProfilePreviewPhase
{
private readonly IAnsiConsole _console;
public QualityProfilePreviewPhase(IAnsiConsole console)
{
_console = console;
}
public void Execute(QualityProfileTransactionData transactions)
{
var profileScoreUpdates = transactions.UpdatedProfiles
.ToDictionary(x => x.UpdatedProfile.Name, x => x.UpdatedScores);
var tree = new Tree("Quality Profiles Scores [red](Preview)[/]");
foreach (var (profileName, updatedScores) in profileScoreUpdates)
{
var table = new Table()
.AddColumn("[bold]Custom Format[/]")
.AddColumn("[bold]Current[/]")
.AddColumn("[bold]New[/]")
.AddColumn("[bold]Reason[/]");
foreach (var updatedScore in updatedScores.Where(x => x.Dto.Score != x.NewScore))
{
table.AddRow(
updatedScore.Dto.Name,
updatedScore.Dto.Score.ToString(),
updatedScore.NewScore.ToString(),
updatedScore.Reason.ToString());
}
tree.AddNode($"[yellow]{profileName}[/]")
.AddNode(table);
}
_console.WriteLine();
_console.Write(tree);
_console.WriteLine();
if (transactions.InvalidProfileNames.Any())
{
_console.MarkupLine("The following quality profiles were [red]not found[/]:");
foreach (var name in transactions.InvalidProfileNames)
{
_console.MarkupLine($"[red]x[/] {name}");
}
_console.WriteLine();
}
}
}