Skip to main content
版本: 0.8

Rust API

添加依赖

cargo add --git https://github.com/kcl-lang/lib

快速开始

use kcl_lang::*;
use anyhow::Result;

fn main() -> Result<()> {
let api = API::default();
let args = &ExecProgramArgs {
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)?;
println!("{}", exec_result.yaml_result);
Ok(())
}