From 8b1aae23363ef18a91aeefd32abd3fa8720c120a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 11 Feb 2021 20:23:09 -0600 Subject: use maps, refactor printing of args --- src/slskd/Options.cs | 796 +++++++++++++++++++++++++++------------------------ src/slskd/Program.cs | 108 +++++-- 2 files changed, 498 insertions(+), 406 deletions(-) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 3014bb35..784c33c4 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -19,6 +19,7 @@ namespace slskd { using System; using System.Collections.Generic; + using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Linq; @@ -39,385 +40,366 @@ namespace slskd /// 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