--- xmlTools/trunk/posUpdate/ParametersParser.cs 2013/03/21 10:43:10 714 +++ xmlTools/trunk/posUpdate/ParametersParser.cs 2013/05/08 21:52:38 861 @@ -11,9 +11,10 @@ namespace xmlTools // Define a class to receive parsed values class ParametersParser { - private static string globalFileName=""; - private static string globalElement=""; - private static string globalParentElement=""; + private static string globalFileName = ""; + private static string globalElement = ""; + private static string globalParentElement = ""; + private static bool globalNoBackups = false; [Verb] public static void addValue( @@ -21,7 +22,7 @@ namespace xmlTools ) { initialChecks(); - XmlTools myTools = new XmlTools(globalElement, globalParentElement); + XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups); List filesToProcess = getFilesToProcess(globalFileName); foreach (string currentFile in filesToProcess) { @@ -36,7 +37,7 @@ namespace xmlTools ) { initialChecks(); - XmlTools myTools = new XmlTools(globalElement, globalParentElement); + XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups); List filesToProcess = getFilesToProcess(globalFileName); foreach (string currentFile in filesToProcess) { @@ -49,15 +50,15 @@ namespace xmlTools public static void updateChainValues( [Parameter(Required = true, Description = "The new first value of the chain. All the chain will be updated based on this value")] string newValue, [Parameter(Description = "Value which have some kind of relation with -newVal \n Together with -newVal updates all the values based on the" + - "-newVal and another position specified on -valRelation parameter (basically starts with (newVal-valRelation) ) Is especially useful when" + + "-newvalue and another position specified on -valrelation parameter (basically starts with (newvalue-valrelation) ) Is especially useful when" + "updating multiple related chains (on different files), like multiple objects from one position to another. Don't use with -filename, because" + - "it will only update one file. \nExample: xmlTools.exe -newVal \"1 1 1\" -valRelation \"4 4 4\" -valElement Translation -valParentElement" + + "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:" + "OBANKeyFrame")] string valRelation, - [Parameter(Description = "Only update specific positions. Positions starts with 0, separted multiple positions with space. Example: valPositions=0 1 4")] [MoreThan(-1)] string valPositions + [Parameter(Description = "Only update specific positions. Positions starts with 0, separted multiple positions with space. Example: valpositions=\"0 1 4\"")] [MoreThan(-1)] string valPositions ) { initialChecks(); - XmlTools myTools = new XmlTools(globalElement, globalParentElement); + XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups); List filesToProcess = getFilesToProcess(globalFileName); foreach (string currentFile in filesToProcess) { @@ -70,7 +71,7 @@ namespace xmlTools public static void Invert() { initialChecks(); - XmlTools myTools = new XmlTools(globalElement, globalParentElement); + XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups); List filesToProcess = getFilesToProcess(globalFileName); foreach (string currentFile in filesToProcess) { @@ -85,7 +86,7 @@ namespace xmlTools [Parameter(Required = true, Description = "New value to replace in Element.")] string newValue ) { - XmlTools myTools = new XmlTools(globalElement, globalParentElement); + XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups); List filesToProcess = getFilesToProcess(globalFileName); foreach (string currentFile in filesToProcess) { @@ -101,7 +102,7 @@ namespace xmlTools ) { initialChecks(); - XmlTools myTools = new XmlTools(globalElement, globalParentElement); + XmlTools myTools = new XmlTools(globalElement, globalParentElement, globalNoBackups); List filesToProcess = getFilesToProcess(globalFileName); foreach (string currentFile in filesToProcess) { @@ -130,11 +131,11 @@ namespace xmlTools if (forceInFiles != "") { - myPatch = new XmlPatch(globalFileName, forceInFiles); + myPatch = new XmlPatch(globalFileName, forceInFiles, globalNoBackups); } else { - myPatch = new XmlPatch(globalFileName); + myPatch = new XmlPatch(globalFileName, globalNoBackups); } myPatch.startPatch(); @@ -147,51 +148,47 @@ namespace xmlTools Console.WriteLine("\nWritten by s10k"); } + [Verb] + public static void showErrTypes() + { + Array values = Enum.GetValues(typeof(Program.appErrors)); + + foreach (Program.appErrors val in values) + { + Console.WriteLine(Enum.GetName(typeof(Program.appErrors),val) + " : " + (int)val); + } + } + // Global Parameters - [Global] + [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.")] public static void fileName( - [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. + [Parameter(Required = true)] string filename // xml filename. Wildcards accepted. ) { globalFileName = filename; } - [Global] + [Global(Description = "Element to apply the operation.")] public static void element( - [Parameter(Required = true, Description = "Element to apply the operation.")] string element + [Parameter(Required = true)] string element ) { globalElement = element; } - [Global] + [Global(Description = "Parent of the Element to apply the operation.")] public static void parElement( - [Parameter(Required = true, Description = "Parent of the Element to apply the operation.")] string parentElement + [Parameter(Required = true)] string parentElement ) { globalParentElement = parentElement; } - //[PreVerbExecution] - //private static void InitialChecks(PreVerbExecutionContext context) - //{ - // bool elementFound = false; - // foreach(ParameterAndValue param in context.Parameters){ - // if (param.Parameter.Names[0] == "element") - // { - // if(!String.IsNullOrEmpty(param.Value.ToString().Trim())){ - // elementFound = true; - // } - // break; - // } - // } - // if (!elementFound) - // { - // Console.Error.WriteLine("You must specify the element parameter where the operations will be processed."); - // Console.ReadLine(); - // System.Environment.Exit(1); - // } - //} + [Global(Description = "Don't make backup of the files modified. Improves the overall program processing performance.")] + public static void noBackups() + { + globalNoBackups = true; + } // Private functions private static List getFilesToProcess(String filename)