aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-26 22:57:27 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-07-26 22:57:27 -0500
commitc5804abb31bd74f26101ad28acdd5c12273d2a8f (patch)
tree62ce56daa367e80391b043a66c7bd498bd39ecc6 /src/slskd/Program.cs
parente4a7073ea750c6bf3a82b35b81ba3883f8438fb4 (diff)
downloadslskd-c5804abb31bd74f26101ad28acdd5c12273d2a8f.tar.gz
find arguments backed by arrays and pass them as multiValuedArguments
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 9447bb7f..3821078b 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -335,6 +335,18 @@ namespace slskd
{
configurationFile = Path.GetFullPath(configurationFile);
+ var multiValuedArguments = typeof(Options)
+ .GetPropertiesRecursively()
+ .Where(p => p.PropertyType.IsArray)
+ .SelectMany(p =>
+ p.CustomAttributes
+ .Where(a => a.AttributeType == typeof(ArgumentAttribute))
+ .Select(a => new[] { a.ConstructorArguments[0].Value, a.ConstructorArguments[1].Value })
+ .SelectMany(v => v))
+ .Select(v => v.ToString())
+ .Where(v => v != "\u0000")
+ .ToArray();
+
return builder
.AddDefaultValues(
targetType: typeof(Options))
@@ -349,6 +361,7 @@ namespace slskd
provider: new PhysicalFileProvider(Path.GetDirectoryName(configurationFile), ExclusionFilters.None)) // required for locations outside of the app directory
.AddCommandLine(
targetType: typeof(Options),
+ multiValuedArguments,
commandLine: Environment.CommandLine);
}