1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.Text; |
4 |
using System.Xml; |
5 |
using System.IO; |
6 |
using System.Globalization; |
7 |
using System.Text.RegularExpressions; |
8 |
|
9 |
namespace xmlTools |
10 |
{ |
11 |
class Program |
12 |
{ |
13 |
public static readonly string toolsVersion = "0.7d"; |
14 |
|
15 |
public enum appErrors |
16 |
{ |
17 |
// 0-19 Errors with input parameters |
18 |
ERROR_PARAMS = 0, |
19 |
FILE_NOT_FOUND = 1, |
20 |
ELEMENT_NOT_SPECIFIED=2, |
21 |
ELEMENT_NOT_FOUND=3, |
22 |
// 20-199 General application errors |
23 |
BACKUPS_ALREADY_EXISTS=20, |
24 |
NUMBER_VALUES_TO_REPLACE_NE_AVAILABLE_VALUES = 21, |
25 |
INVALID_POSITIONS_RANGE=22, |
26 |
// 200-299 Patch operations errors |
27 |
PATCH_ADDTO_PROCESS_ERROR = 200, |
28 |
PATCH_REMOVE_PROCESS_ERROR = 201, |
29 |
PATCH_COMMAND_PROCESS_ERROR=202, |
30 |
PATCH_ELEMENT_NOT_FOUND=203, |
31 |
PATCH_ADDTO_ERROR_PARSING_XML=204, |
32 |
PATCH_COMMAND_NOT_FOUND=205 |
33 |
} |
34 |
|
35 |
public static void printAppError(appErrors error, string description, bool exitApp=false){ |
36 |
Console.Error.WriteLine("Error Code: "+(int)error); |
37 |
Console.Error.WriteLine(description); |
38 |
|
39 |
if (exitApp) |
40 |
{ |
41 |
Environment.Exit(1); |
42 |
} |
43 |
} |
44 |
|
45 |
static void Main(string[] args) |
46 |
{ |
47 |
try |
48 |
{ |
49 |
//We use a command parse library due to its advantages |
50 |
CLAP.Parser.RunConsole<ParametersParser>(args); |
51 |
} |
52 |
catch (Exception e) |
53 |
{ |
54 |
printAppError(appErrors.ERROR_PARAMS, "Error processing parameters:\n" + e.ToString()); |
55 |
} |
56 |
} |
57 |
} |
58 |
} |