--- xmlTools/trunk/posUpdate/ParametersParser.cs 2013/03/21 10:43:10 714 +++ xmlTools/trunk/posUpdate/ParametersParser.cs 2013/03/26 02:30:48 742 @@ -14,6 +14,7 @@ namespace xmlTools 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) { @@ -57,7 +58,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) { @@ -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(); @@ -148,50 +149,35 @@ namespace xmlTools } // 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)