From 94d46b3eb94c3f846b84afe9e58c651b8c63616d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 16 Feb 2025 17:37:53 -0600 Subject: split script Run into Executable and Command, ensure at least one specified --- src/slskd/Core/Options.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 9f539311..183fcbe5 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -2157,9 +2157,31 @@ namespace slskd /// /// Gets the shell script to invoke. /// - [StringLength(int.MaxValue, MinimumLength = 1)] - [NotNullOrWhiteSpace] - public string Run { get; init; } + public ScriptRunOptions Run { get; init; } = new ScriptRunOptions(); + } + + /// + /// Script run options. + /// + public class ScriptRunOptions : IValidatableObject + { + /// + /// Gets the executable to start. + /// + public string Executable { get; init; } + + /// + /// Gets the command to run. + /// + public string Command { get; init; } + + public IEnumerable Validate(ValidationContext validationContext) + { + if (string.IsNullOrWhiteSpace(Executable) && string.IsNullOrWhiteSpace(Command)) + { + yield return new ValidationResult($"At least one of the {nameof(Executable)} and {nameof(Command)} fields must be specified"); + } + } } /// -- cgit v1.2.3