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

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

-added double quotes support (windows users can now specify paths with spaces)
-returning last error as output (helps AEI debugging)

File size: 1.9 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.8b";
14 private static appErrors lastError;
15
16 public enum appErrors
17 {
18 // 1-19 Errors with input parameters
19 ERROR_PARAMS = 1,
20 FILE_NOT_FOUND = 2,
21 ELEMENT_NOT_SPECIFIED=3,
22 ELEMENT_NOT_FOUND=4,
23 // 20-199 General application errors
24 BACKUPS_ALREADY_EXISTS=20,
25 NUMBER_VALUES_TO_REPLACE_NE_AVAILABLE_VALUES = 21,
26 INVALID_POSITIONS_RANGE=22,
27 // 200-299 Patch operations errors
28 PATCH_ADDTO_PROCESS_ERROR = 200,
29 PATCH_REMOVE_PROCESS_ERROR = 201,
30 PATCH_COMMAND_PROCESS_ERROR=202,
31 PATCH_ELEMENT_NOT_FOUND=203,
32 PATCH_ADDTO_ERROR_PARSING_XML=204,
33 PATCH_COMMAND_NOT_FOUND=205
34 }
35
36 public static void printAppError(appErrors error, string description, bool exitApp=false){
37 Console.Error.WriteLine("Error Code: "+(int)error);
38 Console.Error.WriteLine(description);
39
40 if (exitApp)
41 {
42 Environment.Exit(1);
43 }
44
45 lastError = error;
46 }
47
48 public static int Main(string[] args)
49 {
50 try
51 {
52 //We use a command parse library due to its advantages
53 CLAP.Parser.RunConsole<ParametersParser>(args);
54 return (int)lastError;
55 }
56 catch (Exception e)
57 {
58 printAppError(appErrors.ERROR_PARAMS, "Error processing parameters:\n" + e.ToString());
59 return (int)appErrors.ERROR_PARAMS;
60 }
61 }
62 }
63}
Note: See TracBrowser for help on using the repository browser.