本文整理汇总了C#中CommandLineParser.ShowUsage方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.ShowUsage方法的具体用法?C# CommandLineParser.ShowUsage怎么用?C# CommandLineParser.ShowUsage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineParser
的用法示例。
在下文中一共展示了CommandLineParser.ShowUsage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static int Main(string[] args)
{
#if WINDOWS
// Set the correct directory for our dependency files.
var is32Bit = IntPtr.Size == 4;
var directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
string.Format("Dependencies{0}{1}", Path.DirectorySeparatorChar, is32Bit ? "x32" : "x64"));
SetDllDirectory(directory);
#endif
var content = new BuildContent();
// Parse the command line.
var parser = new CommandLineParser(content)
{
Title = "MonoGame Content Builder\n" +
"Builds optimized game content for MonoGame projects."
};
if (!parser.ParseCommandLine(args))
return -1;
// Process all resoponse files.
foreach (var r in content.ResponseFiles)
{
// Read in all the lines, trim whitespace, and remove empty or comment lines.
var commands = File.ReadAllLines(r).
Select(x => x.Trim()).
Where(x => !string.IsNullOrEmpty(x) && !x.StartsWith("#")).
ToArray();
// Parse the commands like they came from the command line.
if (!parser.ParseCommandLine(commands))
return -1;
}
// Do we have anything to do?
if (!content.HasWork)
{
parser.ShowUsage();
return 0;
}
// Print a startup message.
var buildStarted = DateTime.Now;
if (!content.Quiet)
Console.WriteLine("Build started {0}\n", buildStarted);
// Let the content build.
int successCount, errorCount;
content.Build(out successCount, out errorCount);
// Print the finishing info.
if (!content.Quiet)
{
Console.WriteLine("\nBuild {0} succeeded, {1} failed.\n", successCount, errorCount);
Console.WriteLine("Time elapsed {0:hh\\:mm\\:ss\\.ff}.", DateTime.Now - buildStarted);
}
// Return the error count.
return errorCount;
}