wabbajack/Wabbajack.CLI/Verbs/Validate.cs

55 lines
1.5 KiB
C#
Raw Normal View History

2020-02-08 18:03:49 +00:00
using System;
using System.Threading.Tasks;
2020-02-08 18:03:49 +00:00
using CommandLine;
using Wabbajack.Common;
using Wabbajack.Lib;
using Wabbajack.Lib.Validation;
namespace Wabbajack.CLI.Verbs
{
[Verb("validate", HelpText = @"Validates a Modlist")]
public class Validate : AVerb
2020-02-08 18:03:49 +00:00
{
2020-04-09 22:36:07 +00:00
[IsFile(CustomMessage = "The modlist file %1 does not exist!", Extension = Consts.ModListExtensionString)]
2020-02-08 18:03:49 +00:00
[Option('i', "input", Required = true, HelpText = @"Modlist file")]
2020-04-09 22:36:07 +00:00
public string Input { get; set; } = "";
2020-02-08 18:03:49 +00:00
/// <summary>
/// Runs the Validation of a Modlist
/// </summary>
2020-04-06 13:20:14 +00:00
/// <returns></returns>
2020-04-06 17:14:46 +00:00
protected override async Task<ExitCode> Run()
2020-02-08 18:03:49 +00:00
{
ModList modlist;
try
{
2020-03-28 20:42:45 +00:00
modlist = AInstaller.LoadFromFile((AbsolutePath)Input);
2020-02-08 18:03:49 +00:00
}
2020-02-08 18:47:32 +00:00
catch (Exception e)
2020-02-08 18:03:49 +00:00
{
2020-04-06 13:09:17 +00:00
return CLIUtils.Exit($"Error while loading the Modlist!\n{e}", ExitCode.Error);
2020-02-08 18:03:49 +00:00
}
if (modlist == null)
2020-02-08 18:47:32 +00:00
{
2020-04-06 13:09:17 +00:00
return CLIUtils.Exit($"The Modlist could not be loaded!", ExitCode.Error);
2020-02-08 18:47:32 +00:00
}
2020-02-08 18:03:49 +00:00
var queue = new WorkQueue();
try
{
2020-03-22 15:50:53 +00:00
ValidateModlist.RunValidation(modlist).RunSynchronously();
2020-02-08 18:03:49 +00:00
}
2020-02-08 18:47:32 +00:00
catch (Exception e)
2020-02-08 18:03:49 +00:00
{
2020-04-06 13:09:17 +00:00
return CLIUtils.Exit($"Error during Validation!\n{e}", ExitCode.Error);
2020-02-08 18:03:49 +00:00
}
2020-02-24 17:05:42 +00:00
return CLIUtils.Exit("The Modlist passed the Validation", 0);
2020-02-08 18:03:49 +00:00
}
}
}