Re-add opening Modlists with CLI args

This commit is contained in:
erri120 2022-10-16 14:17:30 +02:00
parent 5a8383d12f
commit 633465b790
No known key found for this signature in database
3 changed files with 32 additions and 17 deletions

View File

@ -17,11 +17,13 @@ using Wabbajack.DTOs.Interventions;
using Wabbajack.Interventions; using Wabbajack.Interventions;
using Wabbajack.LoginManagers; using Wabbajack.LoginManagers;
using Wabbajack.Models; using Wabbajack.Models;
using Wabbajack.Paths;
using Wabbajack.Paths.IO; using Wabbajack.Paths.IO;
using Wabbajack.Services.OSIntegrated; using Wabbajack.Services.OSIntegrated;
using Wabbajack.UserIntervention; using Wabbajack.UserIntervention;
using Wabbajack.Util; using Wabbajack.Util;
using WebView2.Runtime.AutoInstaller; using WebView2.Runtime.AutoInstaller;
using Ext = Wabbajack.Common.Ext;
namespace Wabbajack namespace Wabbajack
{ {
@ -47,10 +49,18 @@ namespace Wabbajack
var args = e.Args; var args = e.Args;
RxApp.MainThreadScheduler.Schedule(0, (_, _) => RxApp.MainThreadScheduler.Schedule(0, (_, _) =>
{ {
if (args.Length > 0) if (args.Length == 1)
{
var arg = args[0].ToAbsolutePath();
if (arg.FileExists() && arg.Extension == Ext.Wabbajack)
{
var mainWindow = _host.Services.GetRequiredService<MainWindow>();
mainWindow!.Show();
return Disposable.Empty;
}
} else if (args.Length > 0)
{ {
var builder = _host.Services.GetRequiredService<CommandLineBuilder>(); var builder = _host.Services.GetRequiredService<CommandLineBuilder>();
builder.Run(e.Args).ContinueWith(async x => builder.Run(e.Args).ContinueWith(async x =>
@ -65,6 +75,8 @@ namespace Wabbajack
mainWindow!.Show(); mainWindow!.Show();
return Disposable.Empty; return Disposable.Empty;
} }
return Disposable.Empty;
}); });
} }

View File

@ -1,13 +1,14 @@
 using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
namespace Wabbajack;
using Wabbajack.Verbs; using Wabbajack.Verbs;
using Wabbajack.CLI.Builder; using Wabbajack.CLI.Builder;
public static class CommandLineBuilderExtensions{ namespace Wabbajack;
public static void AddCLIVerbs(this IServiceCollection services) { public static class CommandLineBuilderExtensions
CommandLineBuilder.RegisterCommand<NexusLogin>(NexusLogin.Definition, c => ((NexusLogin)c).Run); {
services.AddSingleton<NexusLogin>(); public static void AddCLIVerbs(this IServiceCollection services)
{
CommandLineBuilder.RegisterCommand<NexusLogin>(NexusLogin.Definition, c => ((NexusLogin)c).Run);
services.AddSingleton<NexusLogin>();
}
} }
}

View File

@ -25,6 +25,7 @@ using Wabbajack.Messages;
using Wabbajack.Models; using Wabbajack.Models;
using Wabbajack.Networking.WabbajackClientApi; using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.Paths; using Wabbajack.Paths;
using Wabbajack.Paths.IO;
using Wabbajack.UserIntervention; using Wabbajack.UserIntervention;
using Wabbajack.View_Models; using Wabbajack.View_Models;
@ -219,16 +220,17 @@ namespace Wabbajack
private static bool IsStartingFromModlist(out AbsolutePath modlistPath) private static bool IsStartingFromModlist(out AbsolutePath modlistPath)
{ {
/* TODO var args = Environment.GetCommandLineArgs();
if (CLIArguments.InstallPath == null) if (args.Length == 2)
{ {
modlistPath = default; var arg = args[1].ToAbsolutePath();
return false; if (arg.FileExists() && arg.Extension == Ext.Wabbajack)
{
modlistPath = arg;
return true;
}
} }
modlistPath = (AbsolutePath)CLIArguments.InstallPath;
return true;
*/
modlistPath = default; modlistPath = default;
return false; return false;
} }