aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-27 06:38:39 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-07-27 06:38:39 -0500
commit742c8c8a77d28eccda886f0e6ca15d4a05a3cf4d (patch)
tree0b7cb4d34aa4a5b9809e503f221062bfa5c95bbb /src/slskd/Program.cs
parent48d569da0e86f1ec0144713c25cad3a5e767c4d2 (diff)
parent2e04802345be5d887e53351dafc13830f38a9cd7 (diff)
downloadslskd-742c8c8a77d28eccda886f0e6ca15d4a05a3cf4d.tar.gz
Merge branch 'lists' of https://github.com/slskd/slskd into lists
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index a458d0ca..3821078b 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -335,7 +335,17 @@ namespace slskd
{
configurationFile = Path.GetFullPath(configurationFile);
- // todo: write some code here to fetch any properties in options marked with `Attribute` and backed by an array. stuff those arguments into a list for multiValuedArgumetns
+ 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(
@@ -351,7 +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: new[] { "t", "list", "list-of-ints" },
+ multiValuedArguments,
commandLine: Environment.CommandLine);
}