From ee377e55fa9bc15a5ac9c432411bdf237bd49ea7 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sun, 5 Mar 2023 08:15:54 -0600 Subject: [PATCH] feat: Create configs from templates --- CHANGELOG.md | 4 + .../config_create__p_custom.xml | 2 +- .../runConfigurations/config_create__t.xml | 20 +++ .../Console/Commands/ConfigCreateCommand.cs | 20 ++- .../Console/Settings/ICreateConfigSettings.cs | 8 + .../Config/ConfigCreationProcessor.cs | 39 ++--- .../Processors/Config/ConfigManipulator.cs | 85 +++++++++++ .../Config/IConfigCreationProcessor.cs | 4 +- .../Processors/Config/IConfigCreator.cs | 9 ++ .../Processors/Config/IConfigManipulator.cs | 12 ++ .../Processors/Config/LocalConfigCreator.cs | 49 ++++++ .../Config/TemplateConfigCreator.cs | 100 ++++++++++++ .../ServiceProcessorsAutofacModule.cs | 14 +- .../Extensions/FileSystemExtensions.cs | 6 + .../Config/ConfigAutofacModule.cs | 1 + .../Config/Parsing/ConfigParser.cs | 13 +- .../Config/Parsing/ConfigSaver.cs | 24 +++ .../Config/Parsing/ConfigYamlDataObjects.cs | 4 +- .../Config/Parsing/ConfigurationLoader.cs | 17 ++- .../Services/ConfigTemplateGuideService.cs | 16 +- .../Config/Yaml/IYamlSerializerFactory.cs | 1 + .../Config/Yaml/YamlSerializerFactory.cs | 29 +++- .../ExceptionTypes/FatalException.cs | 19 +++ .../Config/ConfigManipulatorTest.cs | 53 +++++++ .../Config/TemplateConfigCreatorTest.cs | 143 ++++++++++++++++++ .../Processors/ConfigCreationProcessorTest.cs | 57 +++++-- .../Recyclarr.Cli.Tests.csproj | 3 + .../AutoFixture/CustomizeWithAttribute.cs | 31 ++++ .../Recyclarr.TestLibrary.csproj | 3 + .../Recyclarr.TestLibrary/TestableLogger.cs | 45 ++++++ .../Recyclarr.TrashLib.TestLibrary.csproj | 1 - .../Listers/ConfigTemplateListerTest.cs | 8 +- .../Config/Parsing/ConfigSaverTest.cs | 72 +++++++++ .../ConfigTemplateGuideServiceTest.cs | 2 +- 34 files changed, 840 insertions(+), 74 deletions(-) create mode 100644 src/.idea/.idea.Recyclarr/.idea/runConfigurations/config_create__t.xml create mode 100644 src/Recyclarr.Cli/Console/Settings/ICreateConfigSettings.cs create mode 100644 src/Recyclarr.Cli/Processors/Config/ConfigManipulator.cs create mode 100644 src/Recyclarr.Cli/Processors/Config/IConfigCreator.cs create mode 100644 src/Recyclarr.Cli/Processors/Config/IConfigManipulator.cs create mode 100644 src/Recyclarr.Cli/Processors/Config/LocalConfigCreator.cs create mode 100644 src/Recyclarr.Cli/Processors/Config/TemplateConfigCreator.cs create mode 100644 src/Recyclarr.TrashLib/Config/Parsing/ConfigSaver.cs create mode 100644 src/Recyclarr.TrashLib/ExceptionTypes/FatalException.cs create mode 100644 src/tests/Recyclarr.Cli.Tests/Processors/Config/ConfigManipulatorTest.cs create mode 100644 src/tests/Recyclarr.Cli.Tests/Processors/Config/TemplateConfigCreatorTest.cs create mode 100644 src/tests/Recyclarr.TestLibrary/AutoFixture/CustomizeWithAttribute.cs create mode 100644 src/tests/Recyclarr.TestLibrary/TestableLogger.cs create mode 100644 src/tests/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigSaverTest.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 33e844c5..8c3956b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ changes you may need to make. - The `*.yaml` extension is now accepted for all YAML files (e.g. `settings.yaml`, `recyclarr.yaml`) in addition to `*.yml` (which was already supported). +- New `--template` option added to `config create` which facilitates creating new configuration + files from the configuration template repository. +- New `--force` option added to the `config create` command. This will overwrite existing + configuration files, if they exist. ### Changed diff --git a/src/.idea/.idea.Recyclarr/.idea/runConfigurations/config_create__p_custom.xml b/src/.idea/.idea.Recyclarr/.idea/runConfigurations/config_create__p_custom.xml index e93f7ef9..edef64d7 100644 --- a/src/.idea/.idea.Recyclarr/.idea/runConfigurations/config_create__p_custom.xml +++ b/src/.idea/.idea.Recyclarr/.idea/runConfigurations/config_create__p_custom.xml @@ -1,6 +1,6 @@ -