Lukianol.Arguments is a small assembly to work with your application arguments in a nice way. Using this API a developer can define his mapping of arguments, make them required, add custom validation rules, get a report of failed validations and more. An alpha version of this assembly has been released. Please use at your own risk.

Lukianol.Arguments By Example

#1 Fluent mapping using the API:

          var map = new ArgumentsMap()                                   
                              .RequiredWhenSwitched("useProxy", "Provide a username for the proxy")
                              .RequiredWhenSwitched("useProxy", "Provide a password for the proxy")

#2 Dynamic result support:

        public void DynamicArgumentsParserResultShouldWork()
            var args = new List<string>

            var map = new ArgumentsMap()

            var parser = new ArgumentParser(map);

            var result = parser.ParseAsDynamicResult(args);

            Assert.AreEqual(TimeSpan.FromSeconds(5), result.Timeout);

#3 Coerce Value Support

This is useful for example when you may ask a user to input data on parsing. Check the test below

        public void CoerceValueWorks()
            var map = new ArgumentsMap().AddKnownArgument("password")
                .CoerceValue((v, name) =>
                                     Assert.AreEqual("password", name);
                                     return "entered_from_console";


            var result = new ArgumentParser(map).Parse(null);

            Assert.AreEqual("entered_from_console", result["password"]);

Experimental - here you can find experimental functions which are not included in Downloads but exists in the head revision of the source code

Last edited Apr 28, 2011 at 8:09 PM by ljuk, version 11


No comments yet.