aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-02-16 17:37:53 -0600
committerJP Dillingham <jp@dillingham.me>2025-02-16 17:37:53 -0600
commit94d46b3eb94c3f846b84afe9e58c651b8c63616d (patch)
tree6b5a6a05245c122551881c9689e85dfb89e85bb6 /src
parent13a315c9e858255ce773a4501c0c6c223e6f21f5 (diff)
downloadslskd-94d46b3eb94c3f846b84afe9e58c651b8c63616d.tar.gz
split script Run into Executable and Command, ensure at least one specified
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Options.cs28
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>