Skip to content
/ lib Public
forked from kcl-lang/lib

KCL Artifact Library for SDKs

Notifications You must be signed in to change notification settings

zongz1024/lib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KCL Artifact Library for SDKs

This repo mainly includes the binding of the low-level API and spec of the KCL language core, and the SDKs of various languages are based on this to encapsulate higher-level APIs.

Rust

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

Write the Code

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(())
}

Go

go get kcl-lang.io/lib

Write the Code

package main

import (
	"kcl-lang.io/lib"
)

func main() {
    path = "path/to/install/lib"
    _ := lib.InstallKclvm(path)
}

Java

See here for more information.

Python

python3 -m pip install kcl_lib

Write the code

import kcl_lib.api as api

args = api.ExecProgram_Args(k_filename_list=["./tests/test_data/schema.k"])
api = api.API()
result = api.exec_program(args)
print(result.yaml_result)

Node.js

import { execProgram, ExecProgramArgs } from 'kcl-lib'

function main() {
  const result = execProgram(ExecProgramArgs(['__test__/test_data/schema.k']))
  console.log(result.yamlResult)
}

main();

License

FOSSA Status

About

KCL Artifact Library for SDKs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 73.8%
  • Python 11.0%
  • JavaScript 6.3%
  • Rust 4.9%
  • Go 3.4%
  • Makefile 0.6%