You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/Functions.md
+31-13Lines changed: 31 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -263,24 +263,36 @@ Note: This function will work without a devonfw-ide installation.
263
263
***
264
264
265
265
### changeFile <aname="changeFile"></a>
266
+
This function is used to insert, append and replace some text in a file.
266
267
#### parameter
267
-
1. Path of the file to be changed (relative path to the workspace directory)
268
-
2.
269
-
* Path of the file to get the content from or a string, that should be inserted.(relative path to the playbook directory)
270
-
* (Optional) Name of a placeholder
271
-
* (Optional) Line number where u want to insert your code. (Possible lines are: 1...n+1 for N = number of existing lines. File cant be empty)
268
+
This function consist of 2 parameters
269
+
1. First parameter:
270
+
-**Required**
271
+
-**Type**- String
272
+
-**Description**- Path of the file to be changed (relative path to the workspace directory)
273
+
2. Second parameter:
274
+
-**Required**
275
+
-**Type**- JSON Object
276
+
-**Description**-This parameter consist of 3 attributes:
277
+
* First attribute:- The content that you want to insert into the file or the filepath of a file from where you want to insert the content.
278
+
* Second attribute:- (Optional) Name of a placeholder
279
+
* Third attribute:- (Optional) Line number where you want to insert your code. (Possible lines are: 1...n+1 for N = number of existing lines. File cant be empty)
272
280
#### example
273
281
changeFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java", { "file": "files/Placeholder.java", "placeholder": "private static final long serialVersionUID = 1L;" })
274
282
#### details
275
283
##### Path of the file to get the content from or a string, that should be inserted.
276
-
If you want to add content from a file:
277
-
{"file": "[path]"}
278
-
If you want to add a string to a file:
279
-
{"content": "[string]"}
280
-
If you want to add different contents for the katacoda and console runner, then use the properties "fileConsole" and "fileKatacoda" or "contentConsole" and "contentKatacoda":
If you want to insert some content at a specific line, then use "lineNumber" and dont use a placeholder:
283
-
{"lineNumber": "[Line]"}
284
+
* If you want to add content from a file then use:
285
+
286
+
example: {"file": "[path]"}
287
+
* If you want to add a string to a file then use:
288
+
289
+
example: {"content": "[string]"}
290
+
* If you want to add different contents for the katacoda and console runner, then use the properties "fileConsole" and "fileKatacoda" or "contentConsole" and "contentKatacoda":
0 commit comments