diff --git a/source/Reloaded.Mod.Installer/Program.cs b/source/Reloaded.Mod.Installer/Program.cs index 99a67a1b..65586956 100644 --- a/source/Reloaded.Mod.Installer/Program.cs +++ b/source/Reloaded.Mod.Installer/Program.cs @@ -8,10 +8,19 @@ internal class Program public static void Main(string[] args) { // Handle special case of dependency only install. - if (args.Any(s => s.Equals("--dependenciesOnly", StringComparison.OrdinalIgnoreCase))) + foreach (var arg in args) { - InstallDependenciesOnly(); - return; + if (arg.Equals("--dependenciesOnly", StringComparison.OrdinalIgnoreCase)) + { + InstallDependenciesOnly(); + return; + } + + if (arg.Equals("--nogui")) + { + InstallNoGui(); + return; + } } var application = new App(); @@ -21,18 +30,31 @@ public static void Main(string[] args) private static void InstallDependenciesOnly() { - using var progressBar = new ProgressBar(); - var progress = progressBar.HierarchicalProgress; + var model = new MainWindowViewModel(); + using var progressBar = SetupCliInstall("Installing (Dependencies Only)", model); + using var temporaryFolder = new TemporaryFolderAllocation(); + Console.WriteLine($"Using Temporary Folder: {temporaryFolder.FolderPath}"); + Task.Run(() => model.InstallReloadedAsync(temporaryFolder.FolderPath, false, false)).Wait(); + } + private static void InstallNoGui() + { var model = new MainWindowViewModel(); + using var progressBar = SetupCliInstall("Installing (No GUI)", model); + Task.Run(() => model.InstallReloadedAsync()).Wait(); + } + + private static ProgressBar SetupCliInstall(string progressText, MainWindowViewModel model) + { + var progressBar = new ProgressBar(); + var progress = progressBar.HierarchicalProgress; + model = new MainWindowViewModel(); model.PropertyChanged += (sender, eventArgs) => { if (eventArgs.PropertyName == nameof(model.Progress)) - progress.Report(model.Progress / 100.0f, "Installing Dependencies Only"); + progress.Report(model.Progress / 100.0f, progressText); }; - using var temporaryFolder = new TemporaryFolderAllocation(); - Console.WriteLine($"Using Temporary Folder: {temporaryFolder.FolderPath}"); - Task.Run(() => model.InstallReloadedAsync(temporaryFolder.FolderPath, false, false)).Wait(); + return progressBar; } } \ No newline at end of file