Skip to content

Commit

Permalink
docs: update kcl-lang Rust documents
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Dec 6, 2023
1 parent 5e67a25 commit 8a9aef8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@
### How to Use

```shell
cargo add kcl
cargo add kcl-lang
```

Write the Code

```rust
use kcl_lang::*;
use std::path::Path;
use anyhow::Result;

fn main() -> Result<()> {
let api = API::new()?;
let args = &ExecProgramArgs {
work_dir: Path::new(".").join("src").join("testdata").canonicalize().unwrap().display().to_string(),
k_filename_list: vec!["test.k".to_string()],
k_filename_list: vec!["main.k".to_string()],
k_code_list: vec!["a = 1".to_string()],
..Default::default()
};
let exec_result = api.exec_program(args)?;
assert_eq!(exec_result.yaml_result, "alice:\n age: 18");
println!("{}", exec_result.yaml_result);
Ok(())
}
```
Expand Down

0 comments on commit 8a9aef8

Please sign in to comment.