diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Core/Options.cs | 28 |
1 files changed, 25 insertions, 3 deletions
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 /// <summary> /// Gets the shell script to invoke. /// </summary> - [StringLength(int.MaxValue, MinimumLength = 1)] - [NotNullOrWhiteSpace] - public string Run { get; init; } + public ScriptRunOptions Run { get; init; } = new ScriptRunOptions(); + } + + /// <summary> + /// Script run options. + /// </summary> + public class ScriptRunOptions : IValidatableObject + { + /// <summary> + /// Gets the executable to start. + /// </summary> + public string Executable { get; init; } + + /// <summary> + /// Gets the command to run. + /// </summary> + public string Command { get; init; } + + public IEnumerable<ValidationResult> 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"); + } + } } /// <summary> |
