Skip to content

Repository files navigation

Configgy.CommandLineParser

Configgy: The Last Configuration Library for .NET

A Configgy extension that allows command line parsing via CommandLineParser

Build StatusCoverage StatusNuGet Version

Usage

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.

Installation

You can build from this source or you can get it from nuget here: https://www.nuget.org/packages/Configgy.CommandLineParser

About

A Configgy extension that allows command line parsing via CommandLineParser

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages