Skip to content

Commit

Permalink
Added: GUI-less Install to Installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Aug 8, 2022
1 parent b199139 commit d221052
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions source/Reloaded.Mod.Installer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
}

0 comments on commit d221052

Please sign in to comment.