本文整理汇总了C#中CommandLineParser.ShowError方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.ShowError方法的具体用法?C# CommandLineParser.ShowError怎么用?C# CommandLineParser.ShowError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineParser
的用法示例。
在下文中一共展示了CommandLineParser.ShowError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
/// <summary>
/// Run with following arguments:
///
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
static int Main ( string[] args )
{
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
Log.AddListener( new StdLogListener() );
var options = new BuildOptions();
var parser = new CommandLineParser( options );
try {
if ( args.Any( a => a=="/help" )) {
PrintHelp( parser );
return 0;
}
if ( !parser.ParseCommandLine( args ) ) {
return 1;
}
Builder.Build( options );
} catch ( Exception ex ) {
parser.ShowError( ex.Message );
return 1;
}
return 0;
}
示例2: Main
static int Main ( string[] args )
{
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
Log.AddListener( new StdLogListener() );
var options = new Options();
var parser = new CommandLineParser( options );
try {
// parse arguments :
if (!parser.ParseCommandLine( args )) {
return 1;
}
// change extension of output not set :
if (options.Output==null) {
options.Output = Path.ChangeExtension( options.Input, ".scene");
}
//
// run fbx loader :
//
Log.Message("Reading FBX: {0}", options.Input);
var loader = new FbxLoader();
using ( var scene = loader.LoadScene( options.Input, options ) ) {
//
// Save scene :
//
Log.Message("Preparation...");
foreach ( var mesh in scene.Meshes ) {
if (mesh!=null) {
mesh.MergeVertices( options.MergeTolerance );
mesh.DefragmentSubsets(scene, true);
mesh.ComputeTangentFrame();
mesh.ComputeBoundingBox();
}
}
Log.Message("Merging instances...");
scene.DetectAndMergeInstances();
if (options.BaseDirectory!=null) {
Log.Message("Resolving assets path...");
var relativePath = ContentUtils.MakeRelativePath( options.BaseDirectory + @"\", options.Input );
var relativeDir = Path.GetDirectoryName( relativePath );
var sceneDir = Path.GetDirectoryName( options.Input );
Log.Message("...scene directory : {0}", sceneDir);
Log.Message("...scene base directory : {0}", options.BaseDirectory);
Log.Message("...scene relative path : {0}", relativePath);
Log.Message("...scene relative dir : {0}", relativeDir);
foreach ( var mtrl in scene.Materials ) {
ResolveMaterial( mtrl, relativeDir, sceneDir );
}
}
//
// Save scene :
//
Log.Message("Writing binary file: {0}", options.Output);
using ( var stream = File.OpenWrite( options.Output ) ) {
scene.Save( stream );
}
if (options.Report) {
var reportPath = options.Input + ".html";
Log.Message("Writing report: {0}", reportPath);
File.WriteAllText( reportPath, SceneReport.CreateHtmlReport(scene));
}
}
Log.Message("Done.");
} catch ( Exception e ) {
parser.ShowError( "{0}", e.ToString() );
if (options.Wait) {
Log.Message("Press any key to continue...");
Console.ReadKey();
}
return 1;
}
if (options.Wait) {
Log.Message("Press any key to continue...");
Console.ReadKey();
}
return 0;
}