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

Comparing xmlTools/trunk/posUpdate/Program.cs (file contents):
Revision 742 by s10k, Tue Mar 26 02:30:48 2013 UTC vs.
Revision 874 by s10k, Sat May 25 21:53:39 2013 UTC

# Line 1 | Line 1
1   using System;
2   using System.Collections.Generic;
3 using System.Text;
4 using System.Xml;
3   using System.IO;
4 < using System.Globalization;
7 < using System.Text.RegularExpressions;
4 > using System.Text;
5  
6   namespace xmlTools
7   {
8      class Program
9      {
10 <        public static readonly string toolsVersion = "0.8";
10 >        public const string XmlToolsVersion = "0.9"; // const variable are by default static
11 >        private static appErrors lastError = appErrors.NO_ERROR;
12  
13          public enum appErrors
14          {
15 <            // 0-19 Errors with input parameters
16 <            ERROR_PARAMS = 0,
17 <            FILE_NOT_FOUND = 1,
18 <            ELEMENT_NOT_SPECIFIED=2,
19 <            ELEMENT_NOT_FOUND=3,
15 >            // 1-19 Errors with input parameters
16 >            NO_ERROR = 0,
17 >            ERROR_PARAMS = 1,
18 >            FILE_NOT_FOUND = 2,
19 >            ELEMENT_NOT_SPECIFIED = 3,
20 >            ELEMENT_NOT_FOUND = 4,
21              // 20-199 General application errors
22 <            BACKUPS_ALREADY_EXISTS=20,
22 >            BACKUPS_ALREADY_EXISTS = 20,
23              NUMBER_VALUES_TO_REPLACE_NE_AVAILABLE_VALUES = 21,
24 <            INVALID_POSITIONS_RANGE=22,
24 >            INVALID_POSITIONS_RANGE = 22,
25              // 200-299 Patch operations errors
26              PATCH_ADDTO_PROCESS_ERROR = 200,
27              PATCH_REMOVE_PROCESS_ERROR = 201,
28 <            PATCH_COMMAND_PROCESS_ERROR=202,
29 <            PATCH_ELEMENT_NOT_FOUND=203,
30 <            PATCH_ADDTO_ERROR_PARSING_XML=204,
31 <            PATCH_COMMAND_NOT_FOUND=205
28 >            PATCH_COMMAND_PROCESS_ERROR = 202,
29 >            PATCH_ELEMENT_NOT_FOUND = 203,
30 >            PATCH_ADDTO_ERROR_PARSING_XML = 204,
31 >            PATCH_COMMAND_NOT_FOUND = 205,
32 >            PATCH_CODE_PROCESS_ERROR=206,
33 >            PATCH_CODE_NOT_FOUND=207,
34 >            PATCH_CODE_PARSE_XML_OUTPUT_ERROR=208,
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 +            lastError = error;
47          }
48  
49 <        public static void Main(string[] args)
49 >        public static int Main(string[] args)
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              }
67          }
68      }

Diff Legend

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