diff --git a/RedumpTool/Features/PacksFeature.cs b/RedumpTool/Features/PacksFeature.cs index b80a185..5c9a800 100644 --- a/RedumpTool/Features/PacksFeature.cs +++ b/RedumpTool/Features/PacksFeature.cs @@ -43,18 +43,23 @@ namespace RedumpTool.Features /// public override bool Execute() { - // Get values needed more than once - string? outputDirectory = OutputInput.Value; + // Get common values + string? outDir = OutputInput.Value; + string username = UsernameInput.Value ?? string.Empty; + string password = PasswordInput.Value ?? string.Empty; int? attemptCount = AttemptCountInput.Value; int? timeout = TimeoutInput.Value; + // Get specific values + bool useSubfolders = SubfoldersInput.Value; + // Output directory validation - if (!ValidateAndCreateOutputDirectory(outputDirectory)) + if (!ValidateAndCreateOutputDirectory(outDir)) return false; // Login to Redump, if necessary if (!_client.LoggedIn) - _client.Login(UsernameInput.Value ?? string.Empty, PasswordInput.Value ?? string.Empty).Wait(); + _client.Login(username, password).Wait(); // Update client properties _client.Debug = DebugInput.Value; @@ -64,7 +69,7 @@ namespace RedumpTool.Features _client.Timeout = TimeSpan.FromSeconds(timeout.Value); // Start the processing - var processingTask = _client.DownloadPacks(outputDirectory, SubfoldersInput.Value); + var processingTask = _client.DownloadPacks(outDir, useSubfolders); // Retrieve the result processingTask.Wait(); diff --git a/RedumpTool/Features/QueryFeature.cs b/RedumpTool/Features/QueryFeature.cs index 2bc591b..cd7cb6b 100644 --- a/RedumpTool/Features/QueryFeature.cs +++ b/RedumpTool/Features/QueryFeature.cs @@ -57,17 +57,21 @@ namespace RedumpTool.Features /// public override bool Execute() { - // Get values needed more than once - bool onlyList = ListInput.Value; - string? outputDirectory = OutputInput.Value; - string? queryString = QueryInput.Value; + // Get common values + string? outDir = OutputInput.Value; + string username = UsernameInput.Value ?? string.Empty; + string password = PasswordInput.Value ?? string.Empty; int? attemptCount = AttemptCountInput.Value; int? timeout = TimeoutInput.Value; + + // Get specific values + bool onlyList = ListInput.Value; + string? queryString = QueryInput.Value; bool quick = QuickSearchInput.Value; bool convertForwardSlashes = !NoSlashInput.Value; // Output directory validation - if (!onlyList && !ValidateAndCreateOutputDirectory(outputDirectory)) + if (!onlyList && !ValidateAndCreateOutputDirectory(outDir)) return false; // Query verification (and cleanup) @@ -79,7 +83,7 @@ namespace RedumpTool.Features // Login to Redump, if necessary if (!_client.LoggedIn) - _client.Login(UsernameInput.Value ?? string.Empty, PasswordInput.Value ?? string.Empty).Wait(); + _client.Login(username, password).Wait(); // Update client properties _client.Debug = DebugInput.Value; @@ -95,14 +99,14 @@ namespace RedumpTool.Features if (onlyList) processingTask = _client.ListSearchResults(queryString, convertForwardSlashes); else - processingTask = _client.DownloadSearchResults(queryString, outputDirectory, convertForwardSlashes); + processingTask = _client.DownloadSearchResults(queryString, outDir, convertForwardSlashes); } else { if (onlyList) processingTask = _client.ListDiscsResults(queryString, convertForwardSlashes); else - processingTask = _client.DownloadDiscsResults(queryString, outputDirectory, convertForwardSlashes); + processingTask = _client.DownloadDiscsResults(queryString, outDir, convertForwardSlashes); } // Retrieve the result diff --git a/RedumpTool/Features/SiteFeature.cs b/RedumpTool/Features/SiteFeature.cs index c3cd83c..805d5ab 100644 --- a/RedumpTool/Features/SiteFeature.cs +++ b/RedumpTool/Features/SiteFeature.cs @@ -57,16 +57,21 @@ namespace RedumpTool.Features /// public override bool Execute() { - // Get values needed more than once - string? outputDirectory = OutputInput.Value; - int minId = MinimumInput.Value ?? -1; - int maxId = MaximumInput.Value ?? -1; - bool onlyNew = OnlyNewInput.Value; + // Get common values + string? outDir = OutputInput.Value; + string username = UsernameInput.Value ?? string.Empty; + string password = PasswordInput.Value ?? string.Empty; int? attemptCount = AttemptCountInput.Value; int? timeout = TimeoutInput.Value; + // Get specific values + int minId = MinimumInput.Value ?? -1; + int maxId = MaximumInput.Value ?? -1; + bool onlyNew = OnlyNewInput.Value; + bool force = ForceInput.Value; + // Output directory validation - if (!ValidateAndCreateOutputDirectory(outputDirectory)) + if (!ValidateAndCreateOutputDirectory(outDir)) return false; // Range verification @@ -78,7 +83,7 @@ namespace RedumpTool.Features // Login to Redump, if necessary if (!_client.LoggedIn) - _client.Login(UsernameInput.Value ?? string.Empty, PasswordInput.Value ?? string.Empty).Wait(); + _client.Login(username, password).Wait(); // Update client properties _client.Debug = DebugInput.Value; @@ -90,9 +95,9 @@ namespace RedumpTool.Features // Start the processing Task> processingTask; if (onlyNew) - processingTask = _client.DownloadLastModified(outputDirectory, ForceInput.Value); + processingTask = _client.DownloadLastModified(outDir, force); else - processingTask = _client.DownloadSiteRange(outputDirectory, minId, maxId); + processingTask = _client.DownloadSiteRange(outDir, minId, maxId); // Retrieve the result processingTask.Wait(); diff --git a/RedumpTool/Features/UserFeature.cs b/RedumpTool/Features/UserFeature.cs index 2367176..9ad064c 100644 --- a/RedumpTool/Features/UserFeature.cs +++ b/RedumpTool/Features/UserFeature.cs @@ -49,19 +49,24 @@ namespace RedumpTool.Features /// public override bool Execute() { - // Get values needed more than once - bool onlyList = ListInput.Value; - string? outputDirectory = OutputInput.Value; + // Get common values + string? outDir = OutputInput.Value; + string username = UsernameInput.Value ?? string.Empty; + string password = PasswordInput.Value ?? string.Empty; int? attemptCount = AttemptCountInput.Value; int? timeout = TimeoutInput.Value; + // Get specific values + bool onlyNew = OnlyNewInput.Value; + bool onlyList = ListInput.Value; + // Output directory validation - if (!onlyList && !ValidateAndCreateOutputDirectory(outputDirectory)) + if (!onlyList && !ValidateAndCreateOutputDirectory(outDir)) return false; // Login to Redump, if necessary if (!_client.LoggedIn) - _client.Login(UsernameInput.Value ?? string.Empty, PasswordInput.Value ?? string.Empty).Wait(); + _client.Login(username, password).Wait(); // Update client properties _client.Debug = DebugInput.Value; @@ -73,11 +78,11 @@ namespace RedumpTool.Features // Start the processing Task> processingTask; if (onlyList) - processingTask = _client.ListUser(UsernameInput.Value); - else if (OnlyNewInput.Value) - processingTask = _client.DownloadUserLastModified(UsernameInput.Value, outputDirectory); + processingTask = _client.ListUser(username); + else if (onlyNew) + processingTask = _client.DownloadUserLastModified(username, outDir); else - processingTask = _client.DownloadUser(UsernameInput.Value, outputDirectory); + processingTask = _client.DownloadUser(username, outDir); // Retrieve the result processingTask.Wait(); diff --git a/RedumpTool/Features/WIPFeature.cs b/RedumpTool/Features/WIPFeature.cs index f802193..3fa1258 100644 --- a/RedumpTool/Features/WIPFeature.cs +++ b/RedumpTool/Features/WIPFeature.cs @@ -53,16 +53,20 @@ namespace RedumpTool.Features /// public override bool Execute() { - // Get values needed more than once - string? outputDirectory = OutputInput.Value; - int minId = MinimumInput.Value ?? -1; - int maxId = MaximumInput.Value ?? -1; - bool onlyNew = OnlyNewInput.Value; + // Get common values + string? outDir = OutputInput.Value; + string username = UsernameInput.Value ?? string.Empty; + string password = PasswordInput.Value ?? string.Empty; int? attemptCount = AttemptCountInput.Value; int? timeout = TimeoutInput.Value; + // Get specific values + int minId = MinimumInput.Value ?? -1; + int maxId = MaximumInput.Value ?? -1; + bool onlyNew = OnlyNewInput.Value; + // Output directory validation - if (!ValidateAndCreateOutputDirectory(outputDirectory)) + if (!ValidateAndCreateOutputDirectory(outDir)) return false; // Range verification @@ -74,7 +78,7 @@ namespace RedumpTool.Features // Login to Redump, if necessary if (!_client.LoggedIn) - _client.Login(UsernameInput.Value ?? string.Empty, PasswordInput.Value ?? string.Empty).Wait(); + _client.Login(username, password).Wait(); // Update client properties _client.Debug = DebugInput.Value; @@ -86,9 +90,9 @@ namespace RedumpTool.Features // Start the processing Task> processingTask; if (onlyNew) - processingTask = _client.DownloadLastSubmitted(outputDirectory); + processingTask = _client.DownloadLastSubmitted(outDir); else - processingTask = _client.DownloadWIPRange(outputDirectory, minId, maxId); + processingTask = _client.DownloadWIPRange(outDir, minId, maxId); // Retrieve the result processingTask.Wait();