add installation without gui & pass arguments to gui
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Mono.Options;
|
||||
using ModpackUpdater.Manager;
|
||||
using ModpackUpdater.Model;
|
||||
using Mono.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Pilz.Configuration;
|
||||
using Telerik.WinControls;
|
||||
@@ -21,13 +23,13 @@ public static class Program
|
||||
internal static void Main(string[] args)
|
||||
{
|
||||
var options = new Options(args);
|
||||
if (options.InstallWithoutUi)
|
||||
InstallWithoutGui(options.ProfileFolder, options.ModpackConfig);
|
||||
if (options.NoUi)
|
||||
InstallWithoutGui(options.ModpackConfig, options.ProfileFolder, options.Silent);
|
||||
else
|
||||
RunApp();
|
||||
RunApp(options.ModpackConfig, options.ProfileFolder);
|
||||
}
|
||||
|
||||
private static void RunApp()
|
||||
private static void RunApp(string modpackConfig, string profileFolder)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
@@ -36,7 +38,7 @@ public static class Program
|
||||
if (ThemeResolutionService.LoadPackageResource("ModpackUpdater.CustomThemes.Office2019DarkBluePurple.tssp"))
|
||||
ThemeResolutionService.ApplicationThemeName = "Office2019DarkBluePurple";
|
||||
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new Form1(modpackConfig, profileFolder));
|
||||
}
|
||||
|
||||
private static string GetSettingsPath(int? settingsVersion = 2)
|
||||
@@ -70,8 +72,19 @@ public static class Program
|
||||
File.Delete(settingsPath);
|
||||
}
|
||||
|
||||
private static void InstallWithoutGui(string profileFolder, string modpackConfig)
|
||||
private static void InstallWithoutGui(string modpackConfig, string profileFolder, bool silent)
|
||||
{
|
||||
var config = ModpackConfig.LoadFromUrl(modpackConfig);
|
||||
var installer = new ModpackInstaller(config, profileFolder);
|
||||
var result = installer.Check().Result;
|
||||
|
||||
if (result.HasUpdates)
|
||||
{
|
||||
var success = installer.Install(result).Result;
|
||||
if (!silent)
|
||||
Console.WriteLine($"Installation {(success ?? false ? "completed successfully" : "failed")}!");
|
||||
}
|
||||
else if (!silent)
|
||||
Console.WriteLine("No updates available");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user