Implemented new attributes in all verbs

This commit is contained in:
erri120 2020-04-06 15:06:02 +02:00
parent f5082d97e6
commit 0bb8d9e84c
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
4 changed files with 5 additions and 7 deletions

View File

@ -6,6 +6,9 @@ namespace Wabbajack.CLI.Verbs
{
public int Execute()
{
if (!CLIUtils.HasValidArguments(this))
CLIUtils.Exit("The provided arguments are not valid! Check previous messages for more information", -1);
return Run().Result;
}

View File

@ -60,9 +60,6 @@ namespace Wabbajack.CLI.Verbs
protected override async Task<int> Run()
{
if (!CLIUtils.HasValidArguments(this))
CLIUtils.Exit("Arguments are not valid!", -1);
if (Modlist != null && (!Modlist.EndsWith(Consts.ModListExtension) && !Modlist.EndsWith("modlist.txt")))
return CLIUtils.Exit($"The file {Modlist} is not a valid modlist file!", -1);

View File

@ -11,6 +11,7 @@ namespace Wabbajack.CLI.Verbs
[Option('n', "name", Required = true, HelpText = @"Credential to encrypt and store in AppData\Local\Wabbajack")]
public string? Name { get; set; }
[IsFile(CustomMessage = "The input file %1 does not exist!")]
[Option('i', "input", Required = true, HelpText = @"Source data file name")]
public string? Input { get; set; }

View File

@ -11,6 +11,7 @@ namespace Wabbajack.CLI.Verbs
[Verb("validate", HelpText = @"Validates a Modlist")]
public class Validate : AVerb
{
[IsFile(CustomMessage = "The modlist file %1 does not exist!")]
[Option('i', "input", Required = true, HelpText = @"Modlist file")]
public string? Input { get; set; }
@ -26,10 +27,6 @@ namespace Wabbajack.CLI.Verbs
/// </returns>
protected override async Task<int> Run()
{
if (!File.Exists(Input))
return CLIUtils.Exit($"The file {Input} does not exist!", -1);
if (Input != null && !Input.EndsWith(Consts.ModListExtension))
return CLIUtils.Exit($"The file {Input} does not end with {Consts.ModListExtension}!", -1);