当前位置: 首页>>代码示例>>C#>>正文


C# CommandLineParser.ParseArguments方法代码示例

本文整理汇总了C#中CommandLineParser.ParseArguments方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.ParseArguments方法的具体用法?C# CommandLineParser.ParseArguments怎么用?C# CommandLineParser.ParseArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandLineParser的用法示例。


在下文中一共展示了CommandLineParser.ParseArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

 public static Options Parse(string[] args)
 {
     var options = new Options();
     var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
     options.IsValid = parser.ParseArguments(args, options);
     return options;
 }
开发者ID:jmacs,项目名称:zeromq_sandbox,代码行数:7,代码来源:Options.cs

示例2: Parsing_mutually_exclusive_options_and_required_option_fails

        public void Parsing_mutually_exclusive_options_and_required_option_fails()
        {
            var options = new OptionsWithMultipleSetAndOneOption();
            var parser = new CommandLineParser(new CommandLineParserSettings { MutuallyExclusive = true });
            var result = parser.ParseArguments(new string[] { "-g167", "--hue", "205" }, options);

            result.Should().BeFalse();
        }
开发者ID:kopelli,项目名称:commandline,代码行数:8,代码来源:MutuallyExclusiveParsingFixture.cs

示例3: Between_value_options_order_matters

        public void Between_value_options_order_matters()
        {
            var options = new SimpleOptionsWithValueOptionAndValueList();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(
                new string[] { "4321", "ofvalueoption", "-1234", "forvaluelist1", "forvaluelist2", "forvaluelist3" }, options);

            result.Should().BeFalse();
        }
开发者ID:kopelli,项目名称:commandline,代码行数:9,代码来源:ValueOptionAttributeParsingFixture.cs

示例4: Parse_valid_unknown_arguments

        public void Parse_valid_unknown_arguments()
        {
            string[] args = { "--plugin", "addonX", "--filename", "input.dat" };
            var appOptions = new OptionsForAppWithPlugIns();
            var parser = new CommandLineParser(new CommandLineParserSettings {
                IgnoreUnknownArguments = true, CaseSensitive = true });
            var result1 = parser.ParseArguments(args, appOptions);

            result1.Should().BeTrue();
            appOptions.PlugInName.Should().Be("addonX");

            var plugInXOptions = new OptionsOfPlugInX();
            var result2 = parser.ParseArguments(args, plugInXOptions);

            result2.Should().BeTrue();
            plugInXOptions.InputFileName.Should().Be("input.dat");
            plugInXOptions.ReadOffset.Should().Be(10L);
        }
开发者ID:kopelli,项目名称:commandline,代码行数:18,代码来源:UnknownArgumentsFixture.cs

示例5: ParseValidUnknownArguments

        public void ParseValidUnknownArguments()
        {
            string[] args = { "--plugin", "addonX", "--filename", "input.dat" };
            var appOptions = new OptionsForAppWithPlugIns();
            var parser = new CommandLineParser(new CommandLineParserSettings {
                IgnoreUnknownArguments = true, CaseSensitive = true });
            var result1 = parser.ParseArguments(args, appOptions);

            Assert.IsTrue(result1);
            Assert.AreEqual("addonX", appOptions.PlugInName);

            var plugInXOptions = new OptionsOfPlugInX();
            var result2 = parser.ParseArguments(args, plugInXOptions);

            Assert.IsTrue(result2);
            Assert.AreEqual("input.dat", plugInXOptions.InputFileName);
            Assert.AreEqual(10, plugInXOptions.ReadOffset);
        }
开发者ID:dakahler,项目名称:alloclave,代码行数:18,代码来源:UnknownArgumentsFixture.cs

示例6: Parsing_one_mutually_exclusive_option_succeeds

        public void Parsing_one_mutually_exclusive_option_succeeds()
        {
            var options = new OptionsWithDefaultSet();
            var parser = new CommandLineParser(new CommandLineParserSettings {MutuallyExclusive = true});
            var result = parser.ParseArguments(new string[] { "--file=mystuff.xml" }, options);

            result.Should().BeTrue();
            options.FileName.Should().Be("mystuff.xml");
        }
开发者ID:kopelli,项目名称:commandline,代码行数:9,代码来源:MutuallyExclusiveParsingFixture.cs

示例7: Allow_single_dash_as_option_input_value

        public void Allow_single_dash_as_option_input_value()
        {
            var options = new SimpleOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "--string", "-" }, options);

            result.Should().BeTrue();
            options.StringValue.Should().Be("-");
        }
开发者ID:kopelli,项目名称:commandline,代码行数:9,代码来源:CommandLineParserFixture.cs

示例8: DefaultParsingIsCaseSensitive

        public void DefaultParsingIsCaseSensitive()
        {
            ICommandLineParser local = new CommandLineParser();
            var options = new MixedCaseOptions();
            bool result = local.ParseArguments(new string[] { "-a", "alfa", "--beta-OPTION", "beta" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual("alfa", options.AlfaValue);
            Assert.AreEqual("beta", options.BetaValue);
        }
开发者ID:nuxleus,项目名称:commandlineparser,代码行数:10,代码来源:CommandLineParserFixture.cs

示例9: DisablingCaseSensitive

        public void DisablingCaseSensitive()
        {
            ICommandLineParser local = new CommandLineParser(new CommandLineParserSettings(false)); //Ref.: #DGN0001
            var options = new MixedCaseOptions();
            bool result = local.ParseArguments(new string[] { "-A", "alfa", "--Beta-Option", "beta" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual("alfa", options.AlfaValue);
            Assert.AreEqual("beta", options.BetaValue);
        }
开发者ID:charoco,项目名称:commandline,代码行数:10,代码来源:CommandLineParserFixture.cs

示例10: Default_parsing_is_case_sensitive

        public void Default_parsing_is_case_sensitive()
        {
            var parser = new CommandLineParser();
            var options = new MixedCaseOptions();
            var result = parser.ParseArguments(new string[] { "-a", "alfa", "--beta-OPTION", "beta" }, options);

            result.Should().BeTrue();
            options.AlfaValue.Should().Be("alfa");
            options.BetaValue.Should().Be("beta");
        }
开发者ID:kopelli,项目名称:commandline,代码行数:10,代码来源:CommandLineParserFixture.cs

示例11: Setting_help_writer_using_constructor

        public void Setting_help_writer_using_constructor()
        {
            var writer = new StringWriter();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(writer));
            var options = new SimpleOptionsWithHelpOption();

            bool success = parser.ParseArguments(new string[] {"--help"}, options);

            success.Should().BeFalse();
            writer.ToString().Should().Be("MockOptions::GetUsage()");
        }
开发者ID:kopelli,项目名称:commandline,代码行数:11,代码来源:CommandLineParserSettingsFixture.cs

示例12: Correct_input_not_activates_help

        public void Correct_input_not_activates_help()
        {
            var options = new MockOptions();
            var writer = new StringWriter();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(
                    new string[] { "-imath.xml", "-oresult.xml" }, options, writer);

            result.Should().BeTrue();;
            writer.ToString().Length.Should().Be(0);
        }
开发者ID:kopelli,项目名称:commandline,代码行数:11,代码来源:HelpOptionAttributeFixture.cs

示例13: SettingHelpWriterUsingConstructor

        public void SettingHelpWriterUsingConstructor()
        {
            var writer = new StringWriter();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings(writer));
            var options = new SimpleOptionsWithHelpOption();
            
            bool success = parser.ParseArguments(new string[] {"--help"}, options);

            Assert.AreEqual(false, success);
            Assert.AreEqual("MockOptions::GetUsage()", writer.ToString(System.Globalization.CultureInfo.InvariantCulture)); 
        }
开发者ID:hoeness2,项目名称:mcebuddy2,代码行数:11,代码来源:CommandLineParserSettingsFixture.cs

示例14: Parsing_mutually_exclusive_options_and_required_option_succeeds

        public void Parsing_mutually_exclusive_options_and_required_option_succeeds()
        {
            var options = new OptionsWithMultipleSetAndOneOption();
            var parser = new CommandLineParser(new CommandLineParserSettings { MutuallyExclusive = true });
            var result = parser.ParseArguments(new string[] { "-g100", "-h200", "-cRgbColorSet" }, options);

            result.Should().BeTrue();
            options.Green.Should().Be((byte)100);
            options.Hue.Should().Be((short)200);
            options.DefaultColorSet.Should().Be(ColorSet.RgbColorSet);
        }
开发者ID:kopelli,项目名称:commandline,代码行数:11,代码来源:MutuallyExclusiveParsingFixture.cs

示例15: SettingHelpWriterUsingArgument

        public void SettingHelpWriterUsingArgument()
        {
            var writer = new StringWriter();
            ICommandLineParser parser = new CommandLineParser(new CommandLineParserSettings());
            var options = new SimpleOptionsWithHelpOption();

            bool success = parser.ParseArguments(new string[] { "--help" }, options, writer);

            Assert.AreEqual(false, success);
            Assert.AreEqual("MockOptions::GetUsage()", writer.ToString());
        }
开发者ID:jandppw,项目名称:ppwcode-recovered-from-google-code,代码行数:11,代码来源:CommandLineParserSettingsFixture.cs


注:本文中的CommandLineParser.ParseArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。