ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/xmlTools/trunk/posUpdate/Program.cs
(Generate patch)

Comparing:
posUpdate/posUpdate/Program.cs (file contents), Revision 710 by s10k, Thu Mar 21 10:40:24 2013 UTC vs.
xmlTools/trunk/posUpdate/Program.cs (file contents), Revision 867 by s10k, Thu May 9 10:37:17 2013 UTC

# Line 10 | Line 10 | namespace xmlTools
10   {
11      class Program
12      {
13 <        public static readonly string toolsVersion = "0.7d";
13 >        public static readonly string toolsVersion = "0.8f";
14 >        private static appErrors lastError = appErrors.NO_ERROR;
15  
16          public enum appErrors
17          {
18 <            // 0-19 Errors with input parameters
19 <            ERROR_PARAMS = 0,
20 <            FILE_NOT_FOUND = 1,
21 <            ELEMENT_NOT_SPECIFIED=2,
22 <            ELEMENT_NOT_FOUND=3,
18 >            // 1-19 Errors with input parameters
19 >            NO_ERROR = 0,
20 >            ERROR_PARAMS = 1,
21 >            FILE_NOT_FOUND = 2,
22 >            ELEMENT_NOT_SPECIFIED = 3,
23 >            ELEMENT_NOT_FOUND = 4,
24              // 20-199 General application errors
25 <            BACKUPS_ALREADY_EXISTS=20,
25 >            BACKUPS_ALREADY_EXISTS = 20,
26              NUMBER_VALUES_TO_REPLACE_NE_AVAILABLE_VALUES = 21,
27 <            INVALID_POSITIONS_RANGE=22,
27 >            INVALID_POSITIONS_RANGE = 22,
28              // 200-299 Patch operations errors
29              PATCH_ADDTO_PROCESS_ERROR = 200,
30              PATCH_REMOVE_PROCESS_ERROR = 201,
31 <            PATCH_COMMAND_PROCESS_ERROR=202,
32 <            PATCH_ELEMENT_NOT_FOUND=203,
33 <            PATCH_ADDTO_ERROR_PARSING_XML=204,
34 <            PATCH_COMMAND_NOT_FOUND=205
31 >            PATCH_COMMAND_PROCESS_ERROR = 202,
32 >            PATCH_ELEMENT_NOT_FOUND = 203,
33 >            PATCH_ADDTO_ERROR_PARSING_XML = 204,
34 >            PATCH_COMMAND_NOT_FOUND = 205
35          }
36  
37 <        public static void printAppError(appErrors error, string description, bool exitApp=false){
38 <            Console.Error.WriteLine("Error Code: "+(int)error);
37 >        public static void printAppError(appErrors error, string description, bool exitApp = false)
38 >        {
39 >            Console.Error.WriteLine("Error Code: " + (int)error);
40              Console.Error.WriteLine(description);
41 <            
41 >
42              if (exitApp)
43              {
44                  Environment.Exit(1);
45              }
46 +
47 +            lastError = error;
48          }
49  
50 <        static void Main(string[] args)
50 >        public static int Main(string[] args)
51          {
47            //long ticksThisTime = 0;
48            //System.Diagnostics.Stopwatch timePerParse = System.Diagnostics.Stopwatch.StartNew();
49
50        
51          
52              try
53              {
54                  //We use a command parse library due to its advantages
55 <                CLAP.Parser.RunConsole<ParametersParser>(args);
55 >                appErrors result = (appErrors)CLAP.Parser.RunConsole<ParametersParser>(args);
56 >                if (result != appErrors.NO_ERROR)
57 >                {
58 >                    lastError = result;
59 >                }
60 >                return (int)lastError;
61              }
62              catch (Exception e)
63              {
64                  printAppError(appErrors.ERROR_PARAMS, "Error processing parameters:\n" + e.ToString());
65 +                return (int)appErrors.ERROR_PARAMS;
66              }
61
62            
63
64            //// Stop the timer, and save the
65            //// elapsed ticks for the operation.
66
67            //timePerParse.Stop();
68            //ticksThisTime = timePerParse.ElapsedTicks;
69            //Console.WriteLine(ticksThisTime);
70            //Console.ReadLine();
67          }
68      }
69   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)