Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Reference from:
# https://github.com/c-bata/go-prompt/blob/master/.github/workflows/test.yml
name: CI
on: [push, pull_request]

jobs:
Test:
name: Unit tests with coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.19

- run: make lint

- name: Running go tests with coverage
env:
GO111MODULE: on
run: |
make cover
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out

Lint:
name: Lint checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.50.1
40 changes: 40 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened,closed,synchronize]

jobs:
CLAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release
uses: cla-assistant/github-action@v2.1.3-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN : ${{ secrets.KCL_LANG_BOT_TOKEN }}
with:
path-to-document: 'https://github.com/kcl-lang/.github/blob/main/CLA.md' # e.g. a CLA or a DCO document

# branch should not be protected
lock-pullrequest-aftermerge: True
path-to-signatures: 'signatures/version1/cla.json'
remote-organization-name: kcl-lang
remote-repository-name: cla.db
branch: 'main'
allowlist: 'test'

#below are the optional inputs - If the optional inputs are not given, then default values will be taken
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
#signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo'
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
#use-dco-flag: true - If you are using DCO instead of CLA
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Reference from:
# https://goreleaser.com/ci/actions/
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
Publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@

# Go workspace file
go.work

build/
.vscode/
.kclvm/

.DS_store
22 changes: 22 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

# .goreleaser.yml
builds:
- id: "kcl"
main: ./kcl.go
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
ldflags:
- "-X kcl-lang.io/cli/pkg/version.version={{.Version}}"
60 changes: 60 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<h1 align="center">KCL Command Line Interface (CLI)</h1>

<p align="center">
<a href="./README.md">English</a> | <a href="./README-zh.md">简体中文</a>
</p>
<p align="center">
<a href="#介绍">介绍</a> | <a href="#安装">安装</a> | <a href="#快速开始">快速开始</a>
</p>


<p align="center">
<img src="https://coveralls.io/repos/github/kcl-lang/cli/badge.svg">
<img src="https://img.shields.io/badge/license-Apache--2.0-green">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen">
</p>

## 介绍

`kcl` 是一个命令行界面,包括语言核心功能、IDE功能、包管理工具、社区集成和其他工具等。

## 安装

### 使用脚本安装

### 使用 `go install` 安装

您可以使用 `go install` 命令安装 `kcl`。

```shell
go install kcl-lang.io/cli@latest
```

### 从 Github Release 页面手动安装

您也可以从 Github Release 中获取 `kcl` ,并将 `kcl` 的二进制文件路径设置到环境变量 PATH 中。

```shell
# KCL_INSTALLATION_PATH 是 `kcl` 二进制文件的所在目录.
export PATH=$KCL_INSTALLATION_PATH:$PATH
```

请使用以下命令以确保您成功安装了 `kcl`。

```shell
kcl --help
```

### 从源代码构建

## 快速开始

```shell
kcl run ./examples/kubernetes.k
```

## 常见问题 (FAQ)

##### Q: 我在使用 `go install` 安装 `kcl` 后,出现了 `command not found` 的错误。

A: `go install` 默认会将二进制文件安装到 `$GOPATH/bin` 目录下,您需要将 `$GOPATH/bin` 添加到环境变量 `PATH` 中。
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# cli
The KCL Command Line Interface (CLI)
<h1 align="center">KCL CLI</h1>

<p align="center">
<a href="./README.md">English</a> | <a href="./README-zh.md">简体中文</a>
</p>
<p align="center">
<a href="#introduction">Introduction</a> | <a href="#installation">Installation</a> | <a href="#quick-start">Quick start</a>
</p>

<p align="center">
<img src="https://coveralls.io/repos/github/kcl-lang/cli/badge.svg">
<img src="https://img.shields.io/badge/license-Apache--2.0-green">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen">
</p>

## Introduction

`kcl` is the KCL package manager. `KCL CLI` downloads your KCL package's dependencies, compiles your KCL packages, makes packages, and uploads them to the kcl package registry.

## Installation

### Scripts

### Go install

You can download `kcl` via `go install`.

```shell
go install kcl-lang.io/cli@latest
```

### Download from GITHUB Release Page

You can also get `kcl` from the github release and set the binary path to the environment variable PATH.

```shell
# KCL CLI_INSTALLATION_PATH is the path of the `KCL CLI` binary.
export PATH=$KCL CLI_INSTALLATION_PATH:$PATH
```

Use the following command to ensure that you install `kcl` successfully.

```shell
kcl --help
```

### Build from Source Code

## Quick Start

```shell
kcl run ./examples/kubernetes.k
```

## Frequently Asked Questions (FAQ)

### Q: I am using `go install` to install `kcl`, but I get the error `command not found`.

- A: `go install` will install the binary file to `$GOPATH/bin` by default. You need to add `$GOPATH/bin` to the environment variable `PATH`.

## Learn More

- [KCL Website](https://kcl-lang.io)
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.7.0-alpha.1
94 changes: 94 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// #### Language & Tooling Commands
//
// ```
// kcl
//
// run compile kcl package from a url or filepath
// build build the kcl package
// check check the current package, but don't build target files
// doc documentation tool
// fmt format tool
// lint lint tool
// test unit/integration/benchmark test tool
// lsp language server tool
// clean remove object files and cached files
//
// ```
//
// #### Package & Registry Related Commands (mod and registry workspace)
//
// ```
// kcl
//
// mod init initialize new module in current directory
// mod search search a command from regisry
// mod add add new dependency
// mod remove remove dependency
// mod update update dependency
// mod pkg package a kcl package into tar
// mod metadata output the resolved dependencies of a package
// mod push push kcl package to OCI registry.
// mod pull pull kcl package from OCI registry.
// registry login login to a registry
// registry logout logout from a registry
//
// ```
//
// #### Integration Commands
//
// ```
// kcl
//
// import migration other data and schema to kcl e.g., openapi, jsonschema, json, yaml
// export convert kcl schema to other schema e.g., openapi
//
// ```
//
// #### Plugin Commands (plugin workspace)
//
// ```
// kcl
//
// plugin install install one or more kcl command plugins
// plugin list list installed command plugins
// plugin uninstall uninstall one or more command plugins
// plugin update update one or more command plugins
//
// ```
//
// #### Version and Help Commands
//
// ```
// kcl
//
// help, h Shows a list of commands or help for one command
// version Shows the command version
//
// ```
package cmd

import (
"github.com/spf13/cobra"
)

const rootCmdShortUsage = "The KCL Command Line Interface (CLI)."
const rootCmdLongUsage = `The KCL Command Line Interface (CLI).

KCL is an open-source, constraint-based record and functional language that
enhances the writing of complex configurations, including those for cloud-native
scenarios. The KCL website: https://kcl-lang.io
`

// New creates a new cobra client
func New() *cobra.Command {
cmd := &cobra.Command{
Use: "kcl",
Short: rootCmdShortUsage,
Long: rootCmdLongUsage,
SilenceUsage: true,
}
cmd.AddCommand(NewVersionCmd())
cmd.AddCommand(NewRunCmd())
cmd.SetHelpCommand(&cobra.Command{}) // Disable the help command
return cmd
}
Loading