A Configgy extension that allows command line parsing via CommandLineParser
First setup Configgy like in the documentation.
Create a command line options class like so: (See here)
classOptions{[Option('t',"text",HelpText="Input text")]publicstringText{get;set;}}Now add the new source to your Config subclass by overwriting the default constructor:
publicclassMyConfig:Config,IMyConfig{publicintMaxThingCount{get{returnGet<int>();}}publicstringDatabaseConectionString{get{returnGet<string>();}}publicDateTimeWhenToShutdown{get{returnGet<DateTime>();}}publicMyConfig(string[]arguments):base(newDictionaryCache(),newAggregateSource(newCommandLineParserSource<Options>(arguments),newEnvironmentVariableSource(),newFileSource(),newConnectionStringsSource(),newAppSettingSource(),newEmbeddedResourceSource(),newDefaultValueAttributeSource()),newAggregateTransformer(),newAggregateValidator(),newAggregateCoercer()){}}This simply reproduces the normal default constructor but adds a CommandLineParserSource as one of the sources using the Options type we've already defined and gives it the arguments to parse.
You can build from this source or you can get it from nuget here: https://www.nuget.org/packages/Configgy.CommandLineParser