diff --git a/documentation/Functions.md b/documentation/Functions.md index d2c00d1e..27fc5d8a 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -203,24 +203,36 @@ createFile("cobigenexample/core/src/main/java/com/example/application/cobigenexa *** ### changeFile +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 | @@ -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 @@ -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") \ No newline at end of file +openFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java")