Skip to content

Commit ec3b3ee

Browse files
committed
chore: update readme with kotlin and swift APIs
Signed-off-by: peefy <xpf6677@163.com>
1 parent 6d56e23 commit ec3b3ee

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,28 @@ function main() {
161161
main();
162162
```
163163

164+
### Kotlin
165+
166+
```kotlin
167+
import com.kcl.api.API
168+
import com.kcl.api.execProgramArgs
169+
170+
val args = execProgramArgs { kFilenameList += "schema.k" }
171+
val api = API()
172+
val result = api.execProgram(args)
173+
```
174+
175+
### Swift
176+
177+
```swift
178+
import KclLib
179+
180+
let api = API()
181+
var execArgs = ExecProgram_Args()
182+
execArgs.kFilenameList.append("schema.k")
183+
let result = try api.execProgram(execArgs)
184+
```
185+
164186
### C++
165187

166188
For CMake, you can use FetchContent to add KCL C++ Lib to your project.
@@ -199,12 +221,12 @@ Write the code
199221

200222
int main()
201223
{
202-
auto args = kcl_lib::ExecProgramArgs();
203-
auto files = rust::Vec<rust::String>();
204-
files.push_back(rust::String("../test_data/schema.k"));
205-
args.k_filename_list = files;
224+
auto args = kcl_lib::ExecProgramArgs {
225+
.k_filename_list = { "../test_data/schema.k" },
226+
};
206227
auto result = kcl_lib::exec_program(args);
207228
std::cout << result.yaml_result.c_str() << std::endl;
229+
return 0;
208230
}
209231
```
210232

0 commit comments

Comments
 (0)