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( |
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 |
|
{ |
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 |
|
{ |
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 |
|
{ |
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 |
|
{ |
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 |
|
{ |
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 |
|
{ |
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(); |
149 |
|
} |
150 |
|
|
151 |
|
// Global Parameters |
152 |
< |
[Global] |
152 |
> |
[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.")] |
153 |
|
public static void fileName( |
154 |
< |
[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. |
154 |
> |
[Parameter(Required = true)] string filename // xml filename. Wildcards accepted. |
155 |
|
) |
156 |
|
{ |
157 |
|
globalFileName = filename; |
158 |
|
} |
159 |
|
|
160 |
< |
[Global] |
160 |
> |
[Global(Description = "Element to apply the operation.")] |
161 |
|
public static void element( |
162 |
< |
[Parameter(Required = true, Description = "Element to apply the operation.")] string element |
162 |
> |
[Parameter(Required = true)] string element |
163 |
|
) |
164 |
|
{ |
165 |
|
globalElement = element; |
166 |
|
} |
167 |
|
|
168 |
< |
[Global] |
168 |
> |
[Global(Description = "Parent of the Element to apply the operation.")] |
169 |
|
public static void parElement( |
170 |
< |
[Parameter(Required = true, Description = "Parent of the Element to apply the operation.")] string parentElement |
170 |
> |
[Parameter(Required = true)] string parentElement |
171 |
|
) |
172 |
|
{ |
173 |
|
globalParentElement = parentElement; |
174 |
|
} |
175 |
|
|
176 |
< |
//[PreVerbExecution] |
177 |
< |
//private static void InitialChecks(PreVerbExecutionContext context) |
178 |
< |
//{ |
179 |
< |
// bool elementFound = false; |
180 |
< |
// 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 |
< |
//} |
176 |
> |
[Global(Description = "Don't make backup of the files modified. Improves the overall program processing performance.")] |
177 |
> |
public static void noBackups() |
178 |
> |
{ |
179 |
> |
globalNoBackups = true; |
180 |
> |
} |
181 |
|
|
182 |
|
// Private functions |
183 |
|
private static List<String> getFilesToProcess(String filename) |