本文整理汇总了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);
}
}
示例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();
}
示例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();
}
示例4: GenerateHelpMessage
public string GenerateHelpMessage()
{
var help = new HelpText
{
AdditionalNewLineAfterOption = true,
AddDashesToOption = true
};
help.AddOptions(this);
return help.ToString();
}
示例5: GetUsage
public string GetUsage()
{
var help = new HelpText
{
AddDashesToOption = true
};
help.AddPreOptionsLine("pneumatictube -f <file> -p <path>");
help.AddOptions(this);
return help.ToString();
}
示例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();
}
示例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
}
示例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();
}
示例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.");
}
示例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();
}
示例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();
}
示例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();
}
示例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
}
示例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
}
示例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
}