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


C# HelpText.ToString方法代码示例

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


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

示例1: Main

        private static void Main(string[] args)
        {
            try
            {
                var options = new Options();
                if (!Parser.Default.ParseArguments(args, options))
                {
                    var helpText = new HelpText("Laan SolutionConverter", Assembly.GetEntryAssembly().GetName().Version.ToString());

                    helpText.AddOptions(options);
                    Console.WriteLine(helpText.ToString());
                    return;
                }

                switch (options.Mode)
                {
                    case Mode.Xml:
                        ConvertToXml(options);
                        break;

                    case Mode.Sln:
                        ConvertToSln(options);
                        break;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
开发者ID:PlutoCYF,项目名称:slnconverter,代码行数:30,代码来源:Program.cs

示例2: GetUsage

        public string GetUsage()
        {
            var help = new HelpText(new HeadingInfo("BottomShelf Host", Assembly.GetExecutingAssembly().GetName().Version.ToString(2)));
            help.Copyright = new CopyrightInfo("Peasant Coder Foundation", DateTime.Now.Year);
            help.AddOptions(this);

            return help.ToString();
        }
开发者ID:tyronegroves,项目名称:BottomShelf,代码行数:8,代码来源:CommandLineParameters.cs

示例3: GetUsage

        public string GetUsage()
        {
            HelpText text = new HelpText(" ");

            text.AddPreOptionsLine("  Usage: SlimNet.ConsoleHost.exe -p14000 -a\"C:\\path\\to\\assemblies\\\"");
            text.AddOptions(this);

            return text.ToString();
        }
开发者ID:corefan,项目名称:SlimNet,代码行数:9,代码来源:CommandLineOptions.cs

示例4: GenerateHelpMessage

		public string GenerateHelpMessage()
		{
			var help = new HelpText
			{
				AdditionalNewLineAfterOption = true,
				AddDashesToOption = true
			};

			help.AddOptions(this);
			return help.ToString();
		}
开发者ID:cubeme,项目名称:safety-sharp,代码行数:11,代码来源:Program.cs

示例5: GetUsage

        public string GetUsage()
        {
            var help = new HelpText
            {
                AddDashesToOption = true
            };

            help.AddPreOptionsLine("pneumatictube -f <file> -p <path>");
            help.AddOptions(this);

            return help.ToString();
        }
开发者ID:hartez,项目名称:PneumaticTube,代码行数:12,代码来源:UploadOptions.cs

示例6: GetUsage

        public string GetUsage()
        {
            var asm = Assembly.GetExecutingAssembly();

            var productName =
                asm.GetCustomAttributes(typeof (AssemblyTitleAttribute), false)
                    .OfType<AssemblyTitleAttribute>()
                    .Single()
                    .Title;
            var productVersion =
                asm.GetCustomAttributes(typeof (AssemblyInformationalVersionAttribute), false)
                    .OfType<AssemblyInformationalVersionAttribute>()
                    .Single()
                    .InformationalVersion;
            var productCopyright =
                asm.GetCustomAttributes(typeof (AssemblyCopyrightAttribute), false)
                    .OfType<AssemblyCopyrightAttribute>()
                    .Single()
                    .Copyright;

            var help = new HelpText
            {
                AddDashesToOption = true,
                AdditionalNewLineAfterOption = true,
                Copyright = productCopyright,
                Heading = new HeadingInfo(productName, productVersion),
                MaximumDisplayWidth = Console.BufferWidth
            };

            var errors = help.RenderParsingErrorsText(this, 2);
            if (!string.IsNullOrEmpty(errors))
            {
                help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
                help.AddPreOptionsLine(errors);
            }

            help.AddPreOptionsLine(" ");
#if !NO_COMMANDLINE
            help.AddPreOptionsLine(((AssemblyLicenseAttribute)assembly
                .GetCustomAttributes(typeof(AssemblyLicenseAttribute), false)
                .Single()).Value.Trim());
#else
            help.AddPreOptionsLine(
                "This is free software. You may redistribute copies of it under the terms of the MIT License <http://www.opensource.org/licenses/mit-license.php>.");
#endif
            help.AddPreOptionsLine(" ");
            help.AddPreOptionsLine(string.Format("{0} [options...] \"<targetpath>\"",
                Process.GetCurrentProcess().ProcessName));

            help.AddOptions(this);

            return help.ToString();
        }
开发者ID:ap0110,项目名称:citizenmp-server-updater,代码行数:53,代码来源:CommandLineOptions.cs

示例7: When_defined_MetaValue_should_be_rendered

        public void When_defined_MetaValue_should_be_rendered()
        {
            // Fixture setup
            // Exercize system 
            var sut = new HelpText("Meta Value.")
                .AddOptions(new FakeOptionsWithMetaValue());

            // Verify outcome
            var lines = sut.ToString().ToNotEmptyLines().TrimStringArray();

            Assert.Equal("i FILE, input-file=FILE    Required. Specify input FILE to be processed.", lines[2]);
            // Teardown
        }
开发者ID:JamisonWhite,项目名称:commandline,代码行数:13,代码来源:HelpTextTests.cs

示例8: GetUsage

        public string GetUsage()
        {
            //ヘッダーの設定
            HeadingInfo head = new HeadingInfo("CreateYoutubeQRCode", "Version 0.1");
            HelpText help = new HelpText(head);
            help.Copyright = new CopyrightInfo("KAJIWARA Yutaka", 2015);

            //全オプションを表示(1行間隔)
            help.AdditionalNewLineAfterOption = true;
            help.AddOptions(this);

            return help.ToString();
        }
开发者ID:kajiwara22,项目名称:CreateYoutubeQRCode,代码行数:13,代码来源:ConsoleOption.cs

示例9: Add_options_with_dashes

        public void Add_options_with_dashes()
        {
            var local = new HelpText {
                AddDashesToOption = true,
                Heading = new HeadingInfo("AddOptionsWithDashes"),
                Copyright = new CopyrightInfo("Author", DateTime.Now.Year)
            };
            local.AddOptions(new MockOptionsSimple());

            string help = local.ToString();

            Console.WriteLine(help);

            string[] lines = help.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            lines[3].Should().Be("  -s, --something    Input something here.");
        }
开发者ID:HyperInfo,项目名称:TimeLaps,代码行数:16,代码来源:HelpTextFixture.cs

示例10: GetUsage

 public string GetUsage()
 {
     var help = new HelpText("GeoIp Example runner", "Copyright 2013", this);
     // ...
     if (this.LastParserState.Errors.Count > 0)
     {
         var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
         if (!string.IsNullOrEmpty(errors))
         {
             help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
             help.AddPreOptionsLine(errors);
         }
     }
     // ...
     return help.ToString();
 }
开发者ID:Wolfium,项目名称:geoip-api-csharp2,代码行数:16,代码来源:Program.cs

示例11: GetSubCommandHelpMessage

        public static string GetSubCommandHelpMessage(object option, string[] usages)
        {
            var helpText = new HelpText(HelpText)
            {
                AdditionalNewLineAfterOption = false,
                AddDashesToOption = true
            };

            bool multiple = usages.Length > 1;
            for (int i = 0; i < usages.Length; i++)
            {
                string title = multiple ? $"Usage{i + 1}" : "Usage";
                AddLinesToHelpText(helpText, $"{Environment.NewLine}{title}: {ProductName} {usages[i]}");
            }

            helpText.AddOptions(option);
            return helpText.ToString();
        }
开发者ID:yodamaster,项目名称:docfx,代码行数:18,代码来源:HelpTextGenerator.cs

示例12: GetUsage

        public string GetUsage()
        {
            var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            // AssemblyCopyrightAttribute asmcpy = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute));

            //ヘッダーの設定
            HeadingInfo head = new HeadingInfo(versionInfo.ProductName, "Version " + versionInfo.ProductVersion);
            HelpText help = new HelpText(head);
            help.Copyright = new CopyrightInfo("T. Minemoto", 2010);
            help.AddPreOptionsLine("University of Hyogo, Research Group of Fundamental Computer Engineering");
            help.AddPreOptionsLine("Usage: MorphExtractroCL.exe -i D:\\input -o out -b 123");

            //全オプションを表示(1行間隔)
            help.AdditionalNewLineAfterOption = false;
            help.AddOptions(this);

            return help.ToString();
        }
开发者ID:Vaa3D,项目名称:vaa3d_tools,代码行数:18,代码来源:ImageProcessRunner.cs

示例13: Create_instance_with_enum_options_disabled

        public void Create_instance_with_enum_options_disabled()
        {
            // Fixture setup
            // Exercize system
            var sut = new HelpText { AddDashesToOption = true }
                .AddPreOptionsLine("pre-options")
                .AddOptions(new FakeOptionsWithHelpTextEnum())
                .AddPostOptionsLine("post-options");

            // Verify outcome

            var lines = sut.ToString().ToNotEmptyLines().TrimStringArray();
            Assert.Equal("pre-options", lines[0]);
            Assert.Equal("--stringvalue    Define a string value here.", lines[1]);
            Assert.Equal("--shape          Define a enum value here.", lines[2]);
            Assert.Equal("--help           Display this help screen.", lines[3]);
            Assert.Equal("post-options", lines[4]);
            // Teardown
        }
开发者ID:Winsto,项目名称:commandline,代码行数:19,代码来源:HelpTextTests.cs

示例14: Create_instance_with_enum_options_disabled

        public void Create_instance_with_enum_options_disabled()
        {
            // Fixture setup
            // Exercize system
            var sut = new HelpText { AddDashesToOption = true }
                .AddPreOptionsLine("pre-options")
                .AddOptions(new NotParsed<FakeOptionsWithHelpTextEnum>(TypeInfo.Create(typeof(FakeOptionsWithHelpTextEnum)), Enumerable.Empty<Error>()))
                .AddPostOptionsLine("post-options");

            // Verify outcome

            var lines = sut.ToString().ToNotEmptyLines().TrimStringArray();
            lines[0].ShouldBeEquivalentTo("pre-options");
            lines[1].ShouldBeEquivalentTo("--stringvalue    Define a string value here.");
            lines[2].ShouldBeEquivalentTo("--shape          Define a enum value here.");
            lines[3].ShouldBeEquivalentTo("--help           Display this help screen.");
            lines[4].ShouldBeEquivalentTo("--version        Display version information.");
            lines[5].ShouldBeEquivalentTo("post-options");
            // Teardown
        }
开发者ID:thoemmi,项目名称:commandline,代码行数:20,代码来源:HelpTextTests.cs

示例15: Create_instance_without_options

        public void Create_instance_without_options()
        {
            // Fixture setup
            // Exercize system
            var sut =
                new HelpText(new HeadingInfo("Unit-tests", "2.0"), new CopyrightInfo(true, "Author", 2005, 2013))
                    .AddPreOptionsLine("pre-options line 1")
                    .AddPreOptionsLine("pre-options line 2")
                    .AddPostOptionsLine("post-options line 1")
                    .AddPostOptionsLine("post-options line 2");

            // Verify outcome
            var lines = sut.ToString().ToNotEmptyLines();

            lines[0].ShouldBeEquivalentTo("Unit-tests 2.0");
            lines[1].ShouldBeEquivalentTo("Copyright (C) 2005 - 2013 Author");
            lines[2].ShouldBeEquivalentTo("pre-options line 1");
            lines[3].ShouldBeEquivalentTo("pre-options line 2");
            lines[4].ShouldBeEquivalentTo("post-options line 1");
            lines[5].ShouldBeEquivalentTo("post-options line 2");
            // Teardown
        }
开发者ID:Ehryk,项目名称:commandline,代码行数:22,代码来源:HelpTextTests.cs


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