Esempio n. 1
0
        private static OutputFormat GetOptions(SimpleParser clap)
        {
            var outputFormat = new OutputFormat {
                A = "a1", R = "r1", G = "g1", B = "b1"
            };

            if (clap.HasOption("alpha"))
            {
                outputFormat.A = clap.Option("alpha");
            }
            if (clap.HasOption("red"))
            {
                outputFormat.R = clap.Option("red");
            }
            if (clap.HasOption("green"))
            {
                outputFormat.G = clap.Option("green");
            }
            if (clap.HasOption("blue"))
            {
                outputFormat.B = clap.Option("blue");
            }
            if (clap.HasOption("output"))
            {
                outputFormat.OutputFilename = clap.Option("output");
            }

            return(outputFormat);
        }
Esempio n. 2
0
        public void Should_parse_options()
        {
            var testArgs = "--option|value|--option2|multi word value".ToArgsArray();

            var parser = new SimpleParser(testArgs);

            Assert.That(parser.Option("option"), Is.EqualTo("value"));
            Assert.That(parser.Option("option2"), Is.EqualTo("multi word value"));
            Assert.That(parser.Arguments.Length, Is.EqualTo(0));
        }
Esempio n. 3
0
        public void Should_parse_combination()
        {
            var testArgs = "argument1|--flag|--option|a value".ToArgsArray();

            var parser = new SimpleParser(testArgs);

            Assert.True(parser.Flag("flag"));
            Assert.That(parser.Option("option"), Is.EqualTo("a value"));
            Assert.That(parser.Arguments.Length, Is.EqualTo(1));
            Assert.That(parser.Arguments[0], Is.EqualTo("argument1"));
        }
Esempio n. 4
0
        public void Should_parse_arguments_from_anywhere()
        {
            var testArgs = "argument1|--flag|--option|a value|argument2".ToArgsArray();

            var parser = new SimpleParser(testArgs);

            Assert.True(parser.Flag("flag"));
            Assert.That(parser.Option("option"), Is.EqualTo("a value"));
            Assert.That(parser.Arguments.Length, Is.EqualTo(2));
            Assert.That(parser.Arguments[0], Is.EqualTo("argument1"));
            Assert.That(parser.Arguments[1], Is.EqualTo("argument2"));
        }