--- xmlTools/posUpdate/Program.cs 2013/03/21 10:40:39 711 +++ xmlTools/trunk/posUpdate/Program.cs 2013/05/25 21:53:39 874 @@ -1,73 +1,69 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Xml; using System.IO; -using System.Globalization; -using System.Text.RegularExpressions; +using System.Text; namespace xmlTools { class Program { - public static readonly string toolsVersion = "0.7d"; + public const string XmlToolsVersion = "0.9"; // const variable are by default static + private static appErrors lastError = appErrors.NO_ERROR; public enum appErrors { - // 0-19 Errors with input parameters - ERROR_PARAMS = 0, - FILE_NOT_FOUND = 1, - ELEMENT_NOT_SPECIFIED=2, - ELEMENT_NOT_FOUND=3, + // 1-19 Errors with input parameters + NO_ERROR = 0, + ERROR_PARAMS = 1, + FILE_NOT_FOUND = 2, + ELEMENT_NOT_SPECIFIED = 3, + ELEMENT_NOT_FOUND = 4, // 20-199 General application errors - BACKUPS_ALREADY_EXISTS=20, + BACKUPS_ALREADY_EXISTS = 20, NUMBER_VALUES_TO_REPLACE_NE_AVAILABLE_VALUES = 21, - INVALID_POSITIONS_RANGE=22, + INVALID_POSITIONS_RANGE = 22, // 200-299 Patch operations errors PATCH_ADDTO_PROCESS_ERROR = 200, PATCH_REMOVE_PROCESS_ERROR = 201, - PATCH_COMMAND_PROCESS_ERROR=202, - PATCH_ELEMENT_NOT_FOUND=203, - PATCH_ADDTO_ERROR_PARSING_XML=204, - PATCH_COMMAND_NOT_FOUND=205 + PATCH_COMMAND_PROCESS_ERROR = 202, + PATCH_ELEMENT_NOT_FOUND = 203, + PATCH_ADDTO_ERROR_PARSING_XML = 204, + PATCH_COMMAND_NOT_FOUND = 205, + PATCH_CODE_PROCESS_ERROR=206, + PATCH_CODE_NOT_FOUND=207, + PATCH_CODE_PARSE_XML_OUTPUT_ERROR=208, } - public static void printAppError(appErrors error, string description, bool exitApp=false){ - Console.Error.WriteLine("Error Code: "+(int)error); + public static void printAppError(appErrors error, string description, bool exitApp = false) + { + Console.Error.WriteLine("Error Code: " + (int)error); Console.Error.WriteLine(description); - + if (exitApp) { Environment.Exit(1); } + lastError = error; } - static void Main(string[] args) + public static int Main(string[] args) { - //long ticksThisTime = 0; - //System.Diagnostics.Stopwatch timePerParse = System.Diagnostics.Stopwatch.StartNew(); - - try { //We use a command parse library due to its advantages - CLAP.Parser.RunConsole(args); + appErrors result = (appErrors)CLAP.Parser.RunConsole(args); + if (result != appErrors.NO_ERROR) + { + lastError = result; + } + return (int)lastError; } catch (Exception e) { printAppError(appErrors.ERROR_PARAMS, "Error processing parameters:\n" + e.ToString()); + return (int)appErrors.ERROR_PARAMS; } - - - - //// Stop the timer, and save the - //// elapsed ticks for the operation. - - //timePerParse.Stop(); - //ticksThisTime = timePerParse.ElapsedTicks; - //Console.WriteLine(ticksThisTime); - //Console.ReadLine(); } } }