mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Using OptionAttribute.Required to check if we need to exit
This commit is contained in:
parent
48332d67f1
commit
f5082d97e6
@ -14,11 +14,6 @@ namespace Wabbajack.CLI
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
internal abstract class AValidateAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Exit the application if validation failed. Will just log if set to false
|
||||
/// </summary>
|
||||
public bool Exit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Custom message if validation failed. Use placeholder %1 to insert the value
|
||||
/// </summary>
|
||||
@ -117,7 +112,9 @@ namespace Wabbajack.CLI
|
||||
: $"The folder {value} does not exist!"
|
||||
: attribute.CustomMessage.Replace("%1", value);
|
||||
|
||||
if (attribute.Exit)
|
||||
var optionAttribute = (OptionAttribute)p.GetAttribute(typeof(OptionAttribute));
|
||||
|
||||
if (optionAttribute.Required)
|
||||
Exit(message, -1);
|
||||
else
|
||||
Log(message);
|
||||
|
@ -17,7 +17,7 @@ namespace Wabbajack.CLI.Verbs
|
||||
[Verb("change-download", HelpText = "Move or Copy all used Downloads from a Modlist to another directory")]
|
||||
public class ChangeDownload : AVerb
|
||||
{
|
||||
[IsDirectory(Exit = true, CustomMessage = "Downloads folder %1 does not exist!")]
|
||||
[IsDirectory(CustomMessage = "Downloads folder %1 does not exist!")]
|
||||
[Option("input", Required = true, HelpText = "Input folder containing the downloads you want to move")]
|
||||
public string? Input { get; set; }
|
||||
|
||||
@ -25,7 +25,7 @@ namespace Wabbajack.CLI.Verbs
|
||||
[Option("output", Required = true, HelpText = "Output folder the downloads should be transferred to")]
|
||||
public string? Output { get; set; }
|
||||
|
||||
[IsFile(Exit = true, CustomMessage = "Modlist file %1 does not exist!")]
|
||||
[IsFile(CustomMessage = "Modlist file %1 does not exist!")]
|
||||
[Option("modlist", Required = true, HelpText = "The Modlist, can either be a .wabbajack or a modlist.txt file")]
|
||||
public string? Modlist { get; set; }
|
||||
|
||||
|
@ -11,7 +11,6 @@ namespace Wabbajack.CLI.Verbs
|
||||
[Option('n', "name", Required = true, HelpText = @"Credential to encrypt and store in AppData\Local\Wabbajack")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
|
||||
[Option('o', "output", Required = true, HelpText = @"Output file for the decrypted data")]
|
||||
public string? Output { get; set; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user