Example #1
0
        private static void SetupOptions(OptionCollection options)
        {
            options.Bind <Configuration, int>(x => x.IntValue, "i") !
            .SetDefaultValue(75)
            .SetDescription("An integer value");

            options.Bind <Configuration, string>(x => x.TextValue, "t") !
            .SetDefaultValue("a cool default")
            .SetDescription("A string value");
        }
Example #2
0
        private static void SetupOptions(OptionCollection options)
        {
            options.Bind <Program, int>(x => Program.IntValue, "i") !
            .SetDefaultValue(75)
            .SetDescription("An integer value");

            options.Bind <Program, string>(x => Program.TextValue, "t") !
            .SetDefaultValue("a cool default")
            .SetDescription("A string value");

            options.Bind <Program, bool>(x => Program.SwitchValue, "s") !
            .SetDefaultValue(false)
            .SetDescription("A switch");
        }
Example #3
0
        protected IOption Bind <TTarget, TProp>(OptionCollection options,
                                                Expression <Func <TTarget, TProp> > propSelector,
                                                TestConfig testConfig)
            where TTarget : class, new()
        {
            var option = options.Bind(propSelector);

            option.Should().NotBeNull();

            var optConfig = testConfig.OptionConfigurations
                            .FirstOrDefault(x =>
                                            option !.ContextPath !.Equals(x.ContextPath,
                                                                          StringComparison.OrdinalIgnoreCase));

            optConfig.Should().NotBeNull();

            option !.AddCommandLineKey(optConfig !.CommandLineKey)
            .SetStyle(optConfig.Style);

            if (optConfig.Required)
            {
                option.IsRequired();
            }
            else
            {
                option.IsOptional();
            }

            optConfig.Option = option;

            return(option);
        }
 private void ConfigureOptions(OptionCollection options)
 {
     options.Bind <SimpleObject, bool>(x => x.Switch, "x");
     options.Bind <SimpleObject, string?>(x => x.Text, "y");
     options.FinishConfiguration();
 }