feat: Add list command for template includes

json-serializing-nullable-fields-issue
Robert Dailey 8 months ago
parent 5bb2bfa8a0
commit 8f267483a2

@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Print date & time log at the end of each completed instance sync (#165).
- Add status indicator when cloning or updating git repos.
- YAML includes are now supported (#175) ([docs][includes]).
- New `--include` option added to `config list templates` to show a list of include templates for
each service type ([docs][listoption]).
### Changed
@ -25,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Error out when duplicate instance names are used.
[includes]: https://recyclarr.dev/wiki/yaml/config-reference/include/
[listoption]: http://recyclarr.dev/wiki/cli/config/list/templates/#include
## [5.3.1] - 2023-08-21

@ -17,8 +17,13 @@ public class ConfigListTemplatesCommand : AsyncCommand<ConfigListTemplatesComman
private readonly IMultiRepoUpdater _repoUpdater;
[SuppressMessage("Design", "CA1034:Nested types should not be visible")]
public class CliSettings : BaseCommandSettings
public class CliSettings : BaseCommandSettings, IConfigListTemplatesSettings
{
[CommandOption("-i|--includes")]
[Description(
"List templates that may be included in YAML, instead of root templates used with `config create`.")]
[UsedImplicitly(ImplicitUseKindFlags.Assign)]
public bool Includes { get; init; }
}
public ConfigListTemplatesCommand(ILogger log, ConfigListTemplateProcessor processor, IMultiRepoUpdater repoUpdater)
@ -33,7 +38,7 @@ public class ConfigListTemplatesCommand : AsyncCommand<ConfigListTemplatesComman
try
{
await _repoUpdater.UpdateAllRepositories(settings.CancellationToken);
_processor.Process();
_processor.Process(settings);
return 0;
}
catch (NoConfigurationFilesException)
@ -44,3 +49,8 @@ public class ConfigListTemplatesCommand : AsyncCommand<ConfigListTemplatesComman
return 1;
}
}
public interface IConfigListTemplatesSettings
{
bool Includes { get; }
}

@ -1,3 +1,4 @@
using Recyclarr.Cli.Console.Commands;
using Recyclarr.TrashLib.Config;
using Recyclarr.TrashLib.Config.Services;
using Spectre.Console;
@ -15,15 +16,19 @@ public class ConfigListTemplateProcessor
_guideService = guideService;
}
public void Process()
public void Process(IConfigListTemplatesSettings settings)
{
ListTemplates();
if (settings.Includes)
{
ListData(_guideService.GetIncludeData());
return;
}
ListData(_guideService.GetTemplateData());
}
private void ListTemplates()
private void ListData(IReadOnlyCollection<TemplatePath> data)
{
var data = _guideService.GetTemplateData();
var table = new Table();
var empty = new Markup("");

@ -1,4 +1,5 @@
using System.IO.Abstractions;
using Recyclarr.Cli.Console.Commands;
using Recyclarr.Cli.Processors.Config;
using Recyclarr.TrashLib.Config;
using Recyclarr.TrashLib.Config.Services;
@ -26,7 +27,10 @@ public class ConfigTemplateListerTest : TrashLibIntegrationFixture
new TemplatePath {Id = "s2", TemplateFile = stubFile, Service = SupportedServices.Sonarr, Hidden = true}
});
sut.Process();
var settings = Substitute.For<IConfigListTemplatesSettings>();
settings.Includes.Returns(false);
sut.Process(settings);
console.Output.Should().NotContain("s2");
}

Loading…
Cancel
Save