diff --git a/CLI/Program.cs b/CLI/Program.cs index f927ea2..c349b33 100644 --- a/CLI/Program.cs +++ b/CLI/Program.cs @@ -49,6 +49,8 @@ internal sealed class TrangaCli : Command if(settings.workingDirectory is not null) TrangaSettings.LoadFromWorkingDirectory(settings.workingDirectory); + else + TrangaSettings.CreateOrUpdate(); if(settings.downloadLocation is not null) TrangaSettings.CreateOrUpdate(downloadDirectory: settings.downloadLocation); diff --git a/Tranga/TrangaArgs.cs b/Tranga/TrangaArgs.cs index 77dfea3..f643d4a 100644 --- a/Tranga/TrangaArgs.cs +++ b/Tranga/TrangaArgs.cs @@ -41,6 +41,8 @@ public partial class Tranga : GlobalBase if (wdp) TrangaSettings.LoadFromWorkingDirectory(workingDirectoryPath![0]); + else + TrangaSettings.CreateOrUpdate(); if(dlp) TrangaSettings.CreateOrUpdate(downloadDirectory: downloadLocationPath![0]); diff --git a/Tranga/TrangaSettings.cs b/Tranga/TrangaSettings.cs index e2b9390..ec44ecc 100644 --- a/Tranga/TrangaSettings.cs +++ b/Tranga/TrangaSettings.cs @@ -37,14 +37,9 @@ public static class TrangaSettings public static void LoadFromWorkingDirectory(string directory) { TrangaSettings.workingDirectory = directory; - if (!File.Exists(settingsFilePath)) - { - return; - } - else - { + if(File.Exists(settingsFilePath)) Deserialize(File.ReadAllText(settingsFilePath)); - } + else return; Directory.CreateDirectory(downloadLocation); Directory.CreateDirectory(workingDirectory); @@ -53,6 +48,8 @@ public static class TrangaSettings public static void CreateOrUpdate(string? downloadDirectory = null, string? pWorkingDirectory = null, int? pApiPortNumber = null, string? pUserAgent = null, bool? pAprilFoolsMode = null) { + if(pWorkingDirectory is null && File.Exists(settingsFilePath)) + LoadFromWorkingDirectory(workingDirectory); TrangaSettings.downloadLocation = downloadDirectory ?? TrangaSettings.downloadLocation; TrangaSettings.workingDirectory = pWorkingDirectory ?? TrangaSettings.workingDirectory; TrangaSettings.apiPortNumber = pApiPortNumber ?? TrangaSettings.apiPortNumber;