From 1b25274177ddb98c49745d89ad31b90a34a3e4ae Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 12 Feb 2021 16:54:03 -0600 Subject: remove map, add remaining attributes --- src/slskd/Options.cs | 537 ++++++++++++++++----------------------------------- 1 file changed, 170 insertions(+), 367 deletions(-) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 784c33c4..912740d1 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -18,373 +18,62 @@ namespace slskd { using System; - using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Diagnostics; - using System.Linq; - using System.Reflection; - using slskd.Common.Configuration; using slskd.Validation; using Soulseek.Diagnostics; using Utility.CommandLine; using Utility.EnvironmentVariables; /// - /// Defines an option mapping. - /// - public record Option(char ShortName, string LongName, string EnvironmentVariable, string Key, Type Type, object Default = null, string Description = null); - - /// - /// Application options (immutable options required at startup). + /// Application options. /// public class Options { - ///// - ///// Gets the list of option mappings. - ///// - ///// - ///// - ///// This array lists all application options. Each element in the list is a mapping object that dictates inputs - ///// (command line, envar, config file) for the option, a default value, description, and most importantly, the - ///// configuration key which will ultimately contain the derived value. - ///// - ///// - ///// Configuration keys are a construct of the namespace and, in a - ///// nutshell, represent an object map as a series of key-value pairs with nested properties represented as - ///// colon-separated strings. Acceptable 'Key' values in this array must either be null (the value will not be - ///// mapped to anything in Options), or a colon-separated string corresponding to a property somewhere inside Options. - ///// - ///// - ///// This mapping exists so that disparate configuration keys from various configuration sources can be overridden - ///// by subsequent sources; for example, --foo (cli), FOOBAR (envar) and foo.bar (yaml) would result in three - ///// distinct keys. With this mapping all three can be made to map to the same key and the application can - ///// dictate order of precedence. - ///// - ///// - ///// Some options, specifically those lacking a 'Key', are derived prior to the configuration file being loaded and - ///// their values are not needed in Options. This approach should be reserved for flags that may result in the - ///// application carrying out a command, and then exiting. For example, --help, --version. These options are - ///// generally properties in and are marked with and - ///// potentially to allow for mapping by other means. - ///// - ///// - ///// The order in which mappings appear in the array dictate the order in which they appear when listed in --help - ///// and --envars. - ///// - ///// - //public static IEnumerable