From 4ea4a70e50d96b01e3ce00268c2a77afef8bfebf Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 20 Jun 2024 22:19:18 +0200 Subject: [PATCH] add option to include/exclude extra files --- ModpackUpdater.Manager/ModpackInstaller.cs | 4 ++-- ModpackUpdater.Manager/UpdateCheckOptions.cs | 1 + ModpackUpdater.Model/InstallAction.cs | 1 + ModpackUpdater/Options.cs | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index 20db81e..0c2f3f4 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -56,7 +56,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf if (installInfos is not null && installInfos.Actions.Count != 0) { - var actions = installInfos.Actions.Where(n => n.Side.IsSide(options.Side)); + var actions = installInfos.Actions.Where(n => n.Side.IsSide(options.Side) && (!n.IsExtra || options.IncludeExtraActions)); if (actions.Any()) { result.Actions.AddRange(installInfos.Actions); @@ -88,7 +88,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf foreach (var action in checkingVersion.Actions) { - if (action.Side.IsSide(options.Side) && !result.Actions.Any(n => n.DestPath == action.DestPath)) + if (action.Side.IsSide(options.Side) && (!action.IsExtra || options.IncludeExtraActions) && !result.Actions.Any(n => n.DestPath == action.DestPath)) actionsToAdd.Add(action); } diff --git a/ModpackUpdater.Manager/UpdateCheckOptions.cs b/ModpackUpdater.Manager/UpdateCheckOptions.cs index bf28bbd..e0c0993 100644 --- a/ModpackUpdater.Manager/UpdateCheckOptions.cs +++ b/ModpackUpdater.Manager/UpdateCheckOptions.cs @@ -7,4 +7,5 @@ public class UpdateCheckOptions public bool IgnoreMaintenance { get; set; } public bool AllowUpdaterAfterInstall { get; set; } = true; public Side Side { get; set; } = Side.Client; + public bool IncludeExtraActions { get; set; } } diff --git a/ModpackUpdater.Model/InstallAction.cs b/ModpackUpdater.Model/InstallAction.cs index 7ec563f..4343378 100644 --- a/ModpackUpdater.Model/InstallAction.cs +++ b/ModpackUpdater.Model/InstallAction.cs @@ -7,4 +7,5 @@ public class InstallAction public string DestPath { get; set; } public string DownloadUrl { get; set; } public Side Side { get; set; } = Side.Both; + public bool IsExtra { get; set; } } \ No newline at end of file diff --git a/ModpackUpdater/Options.cs b/ModpackUpdater/Options.cs index e4c4fac..488774a 100644 --- a/ModpackUpdater/Options.cs +++ b/ModpackUpdater/Options.cs @@ -24,6 +24,7 @@ internal class Options { "uai", "Allow an update directly after install. This only has affect if there is no existing installation.", uai => UpdateOptions.AllowUpdaterAfterInstall = uai != null}, { "noupdate", "Skip the update check.", noupdate => UpdateOptions.NoUpdate = noupdate != null}, { "m|maintenance", "Ignores the maintenance mode.", m => UpdateOptions.IgnoreMaintenance = m != null}, + { "e|extraactions", "Include extra actions.", e => UpdateOptions.IncludeExtraActions = e != null}, }; additionals.AddRange(options.Parse(args));