source: xmlTools/trunk/posUpdate/Program.cs@ 869

Last change on this file since 869 was 868, checked in by s10k, 12 years ago

XmlTools: 0.8g fixed a bug added by the previous versions in patch files, which made them fail. fixed another bug when putting -filename as last parameter in patch file.

File size: 2.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Xml;
5using System.IO;
6using System.Globalization;
7using System.Text.RegularExpressions;
8
9namespace xmlTools
10{
11 class Program
12 {
13 public static readonly string toolsVersion = "0.8g";
14 private static appErrors lastError = appErrors.NO_ERROR;
15
16 public enum appErrors
17 {
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,
26 NUMBER_VALUES_TO_REPLACE_NE_AVAILABLE_VALUES = 21,
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
35 }
36
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
42 if (exitApp)
43 {
44 Environment.Exit(1);
45 }
46 lastError = error;
47 }
48
49 public static int Main(string[] args)
50 {
51 try
52 {
53 //We use a command parse library due to its advantages
54 appErrors result = (appErrors)CLAP.Parser.RunConsole<ParametersParser>(args);
55 if (result != appErrors.NO_ERROR)
56 {
57 lastError = result;
58 }
59 return (int)lastError;
60 }
61 catch (Exception e)
62 {
63 printAppError(appErrors.ERROR_PARAMS, "Error processing parameters:\n" + e.ToString());
64 return (int)appErrors.ERROR_PARAMS;
65 }
66 }
67 }
68}
Note: See TracBrowser for help on using the repository browser.