示例#1
0
            public void WithNoOptions_ReturnsHelp()
            {
                var processor = new CommandLineProcessor(new List <string>());

                processor.Parse(new SampleDriver());
                processor.OptionHelp.Should().HaveCount(c => c > 0);
            }
示例#2
0
            public void ForValidDriver_SetsShowHelp()
            {
                var arguments = new List <string> {
                    "test-performance", "--help"
                };
                var processor = new CommandLineProcessor(arguments);

                processor.Parse(new BaseDriver());
                processor.ShowHelp.Should().BeTrue();
            }
示例#3
0
            public void ForValidDriver_ReturnsText()
            {
                var arguments = new List <string> {
                    "test-performance", "--help"
                };
                var processor = new CommandLineProcessor(arguments);

                processor.Parse(new BaseDriver());
                processor.OptionHelp.Should().NotBeEmpty();
            }
示例#4
0
            public void WhenValidParameterIsMissingValue_ListsInvalidParameter()
            {
                var parameter = "--find";
                var arguments = new List <string> {
                    parameter
                };
                var processor = new CommandLineProcessor(arguments);

                processor.Parse(new SampleDriver()).Execute(options => - 1);
                processor.Errors.Should().Contain(e => e.Contains(parameter));
            }
示例#5
0
            public void ForInvalidParameter_ListsInvalidParameter()
            {
                var parameter = "--not-an-option";
                var arguments = new List <string> {
                    parameter
                };
                var processor = new CommandLineProcessor(arguments);

                processor.Parse(new BaseDriver()).Execute(options => - 1);
                processor.Errors.Should().Contain(e => e.Contains(parameter));
            }
        public static int Main(string[] args)
        {
            _logger = new ConsoleLogger(
                ConsoleLoggerOptions.DisplayBanner
                | ConsoleLoggerOptions.UseLabels
                | ConsoleLoggerOptions.ShowTime);

            using (var processor = new CommandLineProcessor(args))
            {
                processor.WithErrorAction(ShowErrors)
                .WithHelpAction(ShowHelp);

                return(processor.Parse <ProgramOptions>()
                       .Execute(MainCore));
            }
        }