Skip to content

Commit 1deb88a

Browse files
Merge pull request #321 from dixyushi/update-doc-changeFile
update changeFile function content
2 parents 11d1ca2 + fb7b010 commit 1deb88a

1 file changed

Lines changed: 31 additions & 13 deletions

File tree

documentation/Functions.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,24 +263,36 @@ Note: This function will work without a devonfw-ide installation.
263263
***
264264

265265
### changeFile <a name="changeFile"></a>
266+
This function is used to insert, append and replace some text in a file.
266267
#### 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)
272280
#### example
273281
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;" })
274282
#### details
275283
##### 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":
281-
{"fileConsole": "[pathToConsoleFile]", "fileKatacoda": "[pathToKatacodaFile]"}
282-
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":
291+
292+
example: {"fileConsole": "[pathToConsoleFile]", "fileKatacoda": "[pathToKatacodaFile]"}
293+
* If you want to insert some content at a specific line, then use "lineNumber" and dont use a placeholder:
294+
295+
example: {"lineNumber": "[Line]"}
284296

285297
example:{...,"placeholder": "private int age;"}
286298
| Before | Content or File | After |
@@ -301,6 +313,12 @@ Please try not to use custom placeholders. Keep in mind that you might want to b
301313

302314
The option to insert at a linenumber uses a placeholder inserted by a script and just adds it at the step you also insert the content.
303315

316+
Note:
317+
1. The command for execution will be generated by Katacoda runner, so user will have to execute this command manually.
318+
319+
2. You should not use linenumber and placeholder in the same function.
320+
321+
304322
***
305323

306324
### createFolder <a name="createFolder"></a>

0 commit comments

Comments
 (0)