public static void Main(string[] args) { ConsoleTraceWriter consoleWriter = null; try { // Create a parser ParameterParser <MifConverterParameters> parser = new ParameterParser <MifConverterParameters>(); parameters = parser.Parse(args); // Create the console writer consoleWriter = new ConsoleTraceWriter(MessageWriter.VerbosityType.Information | MessageWriter.VerbosityType.Fatal | MessageWriter.VerbosityType.Error); // Are there any shortcuts if (parameters.Quiet) { consoleWriter.Verbosity = MessageWriter.VerbosityType.None; } else if (parameters.ErrorsOnly) { consoleWriter.Verbosity = MessageWriter.VerbosityType.Error | MessageWriter.VerbosityType.Fatal; } else if (parameters.Debug) { consoleWriter.Verbosity = (MessageWriter.VerbosityType) 15; } else if (parameters.Chatty) { consoleWriter.Verbosity = (MessageWriter.VerbosityType) 31; } else if (parameters.Verbosity != null) { consoleWriter.Verbosity = (MessageWriter.VerbosityType)Convert.ToInt32(parameters.Verbosity); } // Are we doing anything? bool noAction = !parameters.Help && !parameters.ShowVersion && (args.Length == 0 || parameters.Sources == null || parameters.Sources.Count == 0 || parameters.Renderers == null || parameters.Renderers.Count == 0); // IF no parameters, then help will be displayed // Now default System.Diagnostics.Trace.Listeners.Add(consoleWriter); // Display information Console.WriteLine("General Purpose MIF Converter & Render Tool v{0}", Assembly.GetEntryAssembly().GetName().Version); Console.WriteLine("Copyright (C) 2008-2013 Mohawk College of Applied Arts and Technology"); Console.WriteLine("All rights reserved"); // Load extensions loadAssemblies(consoleWriter); // Help being displayed? if (noAction) { Console.WriteLine("\r\nNothing to do! \r\nUsage:"); Console.WriteLine("gpmr --renderer=xxxx --source=source.mif\r\ngpmr --renderer=xxxx source.mif\r\ngpmr --renderer=xxxx --output-dir=out_dir\r\n"); Console.WriteLine("For parameter listing use : gpmr --help"); } else if (parameters.Help) { dumpHelp(); } else if (parameters.ShowVersion) { dumpVersions(); } else { processTranformation(); } // Write out stats Console.WriteLine("\r\nOperation completed, following messages were generated:"); foreach (KeyValuePair <string, Int32> kv in consoleWriter.MessageCount) { Console.WriteLine("{0} -> {1}", kv.Key, kv.Value); } Environment.Exit(0); } catch (Exception e) { Console.WriteLine(e.Message); System.Diagnostics.Debug.Print(e.ToString()); Environment.Exit(1); } #if DEBUG System.Console.ReadKey(); #endif }
public static void Main(string[] args) { ConsoleTraceWriter consoleWriter = null; try { // Create a parser ParameterParser<MifConverterParameters> parser = new ParameterParser<MifConverterParameters>(); parameters = parser.Parse(args); // Create the console writer consoleWriter = new ConsoleTraceWriter(MessageWriter.VerbosityType.Information | MessageWriter.VerbosityType.Fatal | MessageWriter.VerbosityType.Error); // Are there any shortcuts if (parameters.Quiet) consoleWriter.Verbosity = MessageWriter.VerbosityType.None; else if (parameters.ErrorsOnly) consoleWriter.Verbosity = MessageWriter.VerbosityType.Error | MessageWriter.VerbosityType.Fatal; else if (parameters.Debug) consoleWriter.Verbosity = (MessageWriter.VerbosityType)15; else if (parameters.Chatty) consoleWriter.Verbosity = (MessageWriter.VerbosityType)31; else if(parameters.Verbosity != null) consoleWriter.Verbosity = (MessageWriter.VerbosityType)Convert.ToInt32(parameters.Verbosity); // Are we doing anything? bool noAction = !parameters.Help && !parameters.ShowVersion && (args.Length == 0 || parameters.Sources == null || parameters.Sources.Count == 0 || parameters.Renderers == null || parameters.Renderers.Count == 0); // IF no parameters, then help will be displayed // Now default System.Diagnostics.Trace.Listeners.Add(consoleWriter); // Display information Console.WriteLine("General Purpose MIF Converter & Render Tool v{0}", Assembly.GetEntryAssembly().GetName().Version); Console.WriteLine("Copyright (C) 2008-2013 Mohawk College of Applied Arts and Technology"); Console.WriteLine("All rights reserved"); // Load extensions loadAssemblies(consoleWriter); // Help being displayed? if (noAction) { Console.WriteLine("\r\nNothing to do! \r\nUsage:"); Console.WriteLine("gpmr --renderer=xxxx --source=source.mif\r\ngpmr --renderer=xxxx source.mif\r\ngpmr --renderer=xxxx --output-dir=out_dir\r\n"); Console.WriteLine("For parameter listing use : gpmr --help"); } else if (parameters.Help) dumpHelp(); else if (parameters.ShowVersion) dumpVersions(); else processTranformation(); // Write out stats Console.WriteLine("\r\nOperation completed, following messages were generated:"); foreach (KeyValuePair<string, Int32> kv in consoleWriter.MessageCount) Console.WriteLine("{0} -> {1}", kv.Key, kv.Value); Environment.Exit(0); } catch(Exception e) { Console.WriteLine(e.Message); System.Diagnostics.Debug.Print(e.ToString()); Environment.Exit(1); } #if DEBUG System.Console.ReadKey(); #endif }