From 8b2b1302c62370955ce8bf2bef1494d5868370c2 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Thu, 28 Sep 2023 07:52:48 -0500 Subject: [PATCH] fix: Do not render repo update status when `--raw` is used Fixes #215 --- CHANGELOG.md | 5 +++++ .../Console/Commands/ListCustomFormatsCommand.cs | 2 +- .../CustomFormat/CustomFormatDataLister.cs | 11 ++++++++--- src/Recyclarr.Repo/ConsoleMultiRepoUpdater.cs | 14 ++++++++++---- src/Recyclarr.Repo/IMultiRepoUpdater.cs | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d5009cc..3e6afdad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,11 @@ changes you may need to make. was `3.0.4.1098`). - **BREAKING**: Old boolean syntax for `reset_unmatched_scores` is no longer supported. +### Fixed + +- Status text rendered during git repo updates is no longer shown when `--raw` is used with the + `list custom-formats` command (#215). + ## [5.4.3] - 2023-09-16 ### Changed diff --git a/src/Recyclarr.Cli/Console/Commands/ListCustomFormatsCommand.cs b/src/Recyclarr.Cli/Console/Commands/ListCustomFormatsCommand.cs index 8fa327e4..468c736d 100644 --- a/src/Recyclarr.Cli/Console/Commands/ListCustomFormatsCommand.cs +++ b/src/Recyclarr.Cli/Console/Commands/ListCustomFormatsCommand.cs @@ -45,7 +45,7 @@ public class ListCustomFormatsCommand : AsyncCommand ExecuteAsync(CommandContext context, CliSettings settings) { - await _repoUpdater.UpdateAllRepositories(settings.CancellationToken); + await _repoUpdater.UpdateAllRepositories(settings.CancellationToken, settings.Raw); _lister.List(settings); return 0; } diff --git a/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatDataLister.cs b/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatDataLister.cs index 320bf76c..63a109bf 100644 --- a/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatDataLister.cs +++ b/src/Recyclarr.Cli/Pipelines/CustomFormat/CustomFormatDataLister.cs @@ -56,7 +56,9 @@ public class CustomFormatDataLister { if (!raw) { - _console.WriteLine("\nList of Custom Formats in the TRaSH Guides:"); + _console.WriteLine(); + _console.WriteLine("List of Custom Formats in the TRaSH Guides:"); + _console.WriteLine(); } var categories = _guide.GetCustomFormatData(serviceType) @@ -67,18 +69,21 @@ public class CustomFormatDataLister foreach (var cat in categories) { var title = cat.Key is not null ? $"{cat.Key}" : "[No Category]"; - _console.WriteLine($"\n # {title}"); + + _console.WriteLine($" # {title}"); foreach (var cf in cat) { _console.WriteLine($" - {cf.TrashId} # {cf.Name}"); } + + _console.WriteLine(); } if (!raw) { _console.WriteLine( - "\nThe above Custom Formats are in YAML format and ready to be copied & pasted " + + "The above Custom Formats are in YAML format and ready to be copied & pasted " + "under the `trash_ids:` property."); } } diff --git a/src/Recyclarr.Repo/ConsoleMultiRepoUpdater.cs b/src/Recyclarr.Repo/ConsoleMultiRepoUpdater.cs index e298e4d8..d248a10d 100644 --- a/src/Recyclarr.Repo/ConsoleMultiRepoUpdater.cs +++ b/src/Recyclarr.Repo/ConsoleMultiRepoUpdater.cs @@ -13,7 +13,7 @@ public class ConsoleMultiRepoUpdater : IMultiRepoUpdater _repos = repos; } - public async Task UpdateAllRepositories(CancellationToken token) + public async Task UpdateAllRepositories(CancellationToken token, bool hideConsoleOutput = false) { var options = new ParallelOptions { @@ -21,9 +21,15 @@ public class ConsoleMultiRepoUpdater : IMultiRepoUpdater MaxDegreeOfParallelism = 3 }; - await _console.Status().StartAsync("Updating Git Repositories...", async _ => + var task = Parallel.ForEachAsync(_repos, options, async (repo, innerToken) => await repo.Update(innerToken)); + + if (!hideConsoleOutput) + { + await _console.Status().StartAsync("Updating Git Repositories...", _ => task); + } + else { - await Parallel.ForEachAsync(_repos, options, async (repo, innerToken) => await repo.Update(innerToken)); - }); + await task; + } } } diff --git a/src/Recyclarr.Repo/IMultiRepoUpdater.cs b/src/Recyclarr.Repo/IMultiRepoUpdater.cs index c3f2c9cd..006f5696 100644 --- a/src/Recyclarr.Repo/IMultiRepoUpdater.cs +++ b/src/Recyclarr.Repo/IMultiRepoUpdater.cs @@ -2,5 +2,5 @@ namespace Recyclarr.Repo; public interface IMultiRepoUpdater { - Task UpdateAllRepositories(CancellationToken token); + Task UpdateAllRepositories(CancellationToken token, bool hideConsoleOutput = false); }