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

Comparing:
xmlTools/posUpdate/ParametersParser.cs (file contents), Revision 711 by s10k, Thu Mar 21 10:40:39 2013 UTC vs.
xmlTools/trunk/posUpdate/ParametersParser.cs (file contents), Revision 861 by s10k, Wed May 8 21:52:38 2013 UTC

# Line 11 | Line 11 | namespace xmlTools
11      // Define a class to receive parsed values
12      class ParametersParser
13      {
14 <        private static string globalFileName="";
15 <        private static string globalElement="";
16 <        private static string globalParentElement="";
14 >        private static string globalFileName = "";
15 >        private static string globalElement = "";
16 >        private static string globalParentElement = "";
17 >        private static bool globalNoBackups = false;
18  
19          [Verb]
20          public static void addValue(
# Line 21 | Line 22 | namespace xmlTools
22              )
23          {
24              initialChecks();
25 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
25 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
26              List<string> filesToProcess = getFilesToProcess(globalFileName);
27              foreach (string currentFile in filesToProcess)
28              {
# Line 36 | Line 37 | namespace xmlTools
37              )
38          {
39              initialChecks();
40 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
40 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
41              List<string> filesToProcess = getFilesToProcess(globalFileName);
42              foreach (string currentFile in filesToProcess)
43              {
# Line 49 | Line 50 | namespace xmlTools
50          public static void updateChainValues(
51              [Parameter(Required = true, Description = "The new first value of the chain. All the chain will be updated based on this value")] string newValue,
52              [Parameter(Description = "Value which have some kind of relation with -newVal \n Together with -newVal updates all the values based on the" +
53 <                "-newVal and another position specified on -valRelation parameter (basically starts with (newVal-valRelation) ) Is especially useful when" +
53 >                "-newvalue and another position specified on -valrelation parameter (basically starts with (newvalue-valrelation) ) Is especially useful when" +
54                  "updating multiple related chains (on different files), like multiple objects from one position to another. Don't use with -filename, because" +
55 <                "it will only update one file. \nExample: xmlTools.exe -newVal \"1 1 1\" -valRelation \"4 4 4\" -valElement Translation -valParentElement" +
55 >                "it will only update one file. \nExample: xmlTools.exe updatechainvalues -filename:OBANheli_body_center.xml -newvalue:\"1 1 1\" -valrelation:\"4 4 4\" -element:Translation -parelement:" +
56                  "OBANKeyFrame")] string valRelation,
57 <            [Parameter(Description = "Only update specific positions. Positions starts with 0, separted multiple positions with space. Example: valPositions=0 1 4")] [MoreThan(-1)]  string valPositions
57 >            [Parameter(Description = "Only update specific positions. Positions starts with 0, separted multiple positions with space. Example: valpositions=\"0 1 4\"")] [MoreThan(-1)]  string valPositions
58              )
59          {
60              initialChecks();
61 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
61 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
62              List<string> filesToProcess = getFilesToProcess(globalFileName);
63              foreach (string currentFile in filesToProcess)
64              {
# Line 70 | Line 71 | namespace xmlTools
71          public static void Invert()
72          {
73              initialChecks();
74 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
74 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
75              List<string> filesToProcess = getFilesToProcess(globalFileName);
76              foreach (string currentFile in filesToProcess)
77              {
# Line 85 | Line 86 | namespace xmlTools
86              [Parameter(Required = true, Description = "New value to replace in Element.")] string newValue
87              )
88          {
89 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
89 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
90              List<string> filesToProcess = getFilesToProcess(globalFileName);
91              foreach (string currentFile in filesToProcess)
92              {
# Line 101 | Line 102 | namespace xmlTools
102              )
103          {
104              initialChecks();
105 <            XmlTools myTools = new XmlTools(globalElement, globalParentElement);
105 >            XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups);
106              List<string> filesToProcess = getFilesToProcess(globalFileName);
107              foreach (string currentFile in filesToProcess)
108              {
# Line 130 | Line 131 | namespace xmlTools
131  
132              if (forceInFiles != "")
133              {
134 <                myPatch = new XmlPatch(globalFileName, forceInFiles);
134 >                myPatch = new XmlPatch(globalFileName, forceInFiles, globalNoBackups);
135              }
136              else
137              {
138 <                myPatch = new XmlPatch(globalFileName);
138 >                myPatch = new XmlPatch(globalFileName, globalNoBackups);
139              }
140  
141              myPatch.startPatch();
# Line 147 | Line 148 | namespace xmlTools
148              Console.WriteLine("\nWritten by s10k");
149          }
150  
151 +        [Verb]
152 +        public static void showErrTypes()
153 +        {
154 +            Array values = Enum.GetValues(typeof(Program.appErrors));
155 +
156 +            foreach (Program.appErrors val in values)
157 +            {
158 +                Console.WriteLine(Enum.GetName(typeof(Program.appErrors),val) + " : " + (int)val);
159 +            }
160 +        }
161 +
162          // Global Parameters
163 <        [Global]
163 >        [Global(Description = "Filename to apply the operations (with patchFile specifies the patch filename). Wildcards accepted for multiple files. No filename = search all .xml files in current path.")]
164          public static void fileName(
165 <             [Parameter(Required = true, Description = "Filename to apply the operations (with patchFile specifies the patch filename). Wildcards accepted for multiple files. No filename = search all .xml files in current path.")] string filename // xml filename. Wildcards accepted.
165 >             [Parameter(Required = true)] string filename // xml filename. Wildcards accepted.
166              )
167          {
168              globalFileName = filename;
169          }
170  
171 <        [Global]
171 >        [Global(Description = "Element to apply the operation.")]
172          public static void element(
173 <             [Parameter(Required = true, Description = "Element to apply the operation.")] string element
173 >             [Parameter(Required = true)] string element
174              )
175          {
176              globalElement = element;
177          }
178  
179 <        [Global]
179 >        [Global(Description = "Parent of the Element to apply the operation.")]
180          public static void parElement(
181 <             [Parameter(Required = true, Description = "Parent of the Element to apply the operation.")] string parentElement
181 >             [Parameter(Required = true)] string parentElement
182              )
183          {
184              globalParentElement = parentElement;
185          }
186  
187 <        //[PreVerbExecution]
188 <        //private static void InitialChecks(PreVerbExecutionContext context)
189 <        //{
190 <        //    bool elementFound = false;
191 <        //    foreach(ParameterAndValue param in context.Parameters){
180 <        //        if (param.Parameter.Names[0] == "element")
181 <        //        {
182 <        //            if(!String.IsNullOrEmpty(param.Value.ToString().Trim())){
183 <        //                elementFound = true;
184 <        //            }
185 <        //            break;
186 <        //        }
187 <        //    }
188 <        //    if (!elementFound)
189 <        //    {
190 <        //        Console.Error.WriteLine("You must specify the element parameter where the operations will be processed.");
191 <        //        Console.ReadLine();
192 <        //        System.Environment.Exit(1);
193 <        //    }
194 <        //}
187 >        [Global(Description = "Don't make backup of the files modified. Improves the overall program processing performance.")]
188 >        public static void noBackups()
189 >        {
190 >            globalNoBackups = true;
191 >        }
192  
193          // Private functions
194          private static List<String> getFilesToProcess(String filename)

Diff Legend

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