Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions documentation/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,24 +203,36 @@ createFile("cobigenexample/core/src/main/java/com/example/application/cobigenexa
***

### changeFile <a name="changeFile"></a>
This function is used to insert, append and replace some text in a file.
#### parameter
1. Path of the file to be changed (relative path to the workspace directory)
2.
* Path of the file to get the content from or a string, that should be inserted.(relative path to the playbook directory)
* (Optional) Name of a placeholder
* (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)
This function consist of 2 parameters
1. First parameter:
- **Required**
- **Type**- String
- **Description**- Path of the file to be changed (relative path to the workspace directory)
2. Second parameter:
- **Required**
- **Type**- JSON Object
- **Description**-This parameter consist of 3 attributes:
* 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.
* Second attribute:- (Optional) Name of a placeholder
* 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)
#### example
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;" })
#### details
##### Path of the file to get the content from or a string, that should be inserted.
If you want to add content from a file:
{"file": "[path]"}
If you want to add a string to a file:
{"content": "[string]"}
If you want to add different contents for the katacoda and console runner, then use the properties "fileConsole" and "fileKatacoda" or "contentConsole" and "contentKatacoda":
{"fileConsole": "[pathToConsoleFile]", "fileKatacoda": "[pathToKatacodaFile]"}
If you want to insert some content at a specific line, then use "lineNumber" and dont use a placeholder:
{"lineNumber": "[Line]"}
* If you want to add content from a file then use:

example: {"file": "[path]"}
* If you want to add a string to a file then use:

example: {"content": "[string]"}
* If you want to add different contents for the katacoda and console runner, then use the properties "fileConsole" and "fileKatacoda" or "contentConsole" and "contentKatacoda":

example: {"fileConsole": "[pathToConsoleFile]", "fileKatacoda": "[pathToKatacodaFile]"}
* If you want to insert some content at a specific line, then use "lineNumber" and dont use a placeholder:

example: {"lineNumber": "[Line]"}

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

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.

Note:
1. The command for execution will be generated by Katacoda runner, so user will have to execute this command manually.

2. You should not use linenumber and placeholder in the same function.


***

### createFolder <a name="createFolder"></a>
Expand Down Expand Up @@ -433,4 +451,4 @@ addSetupScript("assets/createProjectScript.sh", "assets/createProjectScript.ps1"
1. Path of the file to be opened (relative path to the workspace directory)

#### example
openFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java")
openFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java")