From 9618a0eadc1005b51f544650e4a937e90665cf89 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Fri, 3 Jun 2022 10:07:24 -0500 Subject: [PATCH] fix: create-config accepts YAML file name again instead of directory --- CHANGELOG.md | 2 ++ docker/entrypoint.sh | 2 +- .../Command/CreateConfigCommandTest.cs | 21 +++++++++++++++++++ src/Recyclarr/Command/CreateConfigCommand.cs | 4 ++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51531b44..68e34b08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Renamed the "EVO (no WEB-DL)" custom format to "EVO (no WEBDL)" in the config template. (#77) - Radarr: `delete_old_custom_formats` works again. (#71) +- The `create-config` subcommand now accepts YAML files again (it was taking a directory before, + which was wrong). [Docker]: https://github.com/recyclarr/recyclarr/wiki/Docker diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 104693bb..d9dd97e5 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,7 +2,7 @@ set -e if [ ! -f "$HOME/recyclarr.yml" ]; then - su-exec recyclarr recyclarr create-config --path "$HOME" + su-exec recyclarr recyclarr create-config --path "$HOME/recyclarr.yml" fi appdata="--app-data $HOME" diff --git a/src/Recyclarr.Tests/Command/CreateConfigCommandTest.cs b/src/Recyclarr.Tests/Command/CreateConfigCommandTest.cs index 25042911..50458593 100644 --- a/src/Recyclarr.Tests/Command/CreateConfigCommandTest.cs +++ b/src/Recyclarr.Tests/Command/CreateConfigCommandTest.cs @@ -1,3 +1,5 @@ +using System.IO.Abstractions; +using System.IO.Abstractions.Extensions; using System.IO.Abstractions.TestingHelpers; using AutoFixture.NUnit3; using CliFx.Infrastructure; @@ -30,4 +32,23 @@ public class CreateConfigCommandTest file.Should().NotBeNull(); file.Contents.Should().NotBeEmpty(); } + + [Test, AutoMockData] + public async Task Config_file_created_when_using_user_specified_path( + [Frozen] IAppPaths paths, + [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs, + CreateConfigCommand cmd) + { + var ymlPath = fs.CurrentDirectory() + .SubDirectory("user") + .SubDirectory("specified") + .File("file.yml").FullName; + + cmd.Path = ymlPath; + await cmd.ExecuteAsync(Substitute.For()); + + var file = fs.GetFile(ymlPath); + file.Should().NotBeNull(); + file.Contents.Should().NotBeEmpty(); + } } diff --git a/src/Recyclarr/Command/CreateConfigCommand.cs b/src/Recyclarr/Command/CreateConfigCommand.cs index 59d51395..14063900 100644 --- a/src/Recyclarr/Command/CreateConfigCommand.cs +++ b/src/Recyclarr/Command/CreateConfigCommand.cs @@ -36,11 +36,11 @@ public class CreateConfigCommand : ICommand public ValueTask ExecuteAsync(IConsole console) { - _appDataSetup.SetupDefaultPath(Path, true); + _appDataSetup.SetupDefaultPath(null, true); var reader = new ResourceDataReader(typeof(Program)); var ymlData = reader.ReadData("config-template.yml"); - var path = _paths.ConfigPath; + var path = _fs.Path.GetFullPath(Path ?? _paths.ConfigPath); if (_fs.File.Exists(path)) {