Skip to content

Commit 1f23098

Browse files
authored
Merge pull request #337 from Peefy/update-kcl-cli-documents
docs: update kcl cli documents
2 parents 14b5d0f + acee867 commit 1f23098

File tree

28 files changed

+329
-106
lines changed

28 files changed

+329
-106
lines changed

blog/2024-04-17-newsletter/index.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ cargo add --git https://github.com/kcl-lang/lib
6666

6767
- The initial release of the KCL Node.js SDK. Repository link: [https://github.com/kcl-lang/lib/tree/main/nodejs](https://github.com/kcl-lang/lib/tree/main/nodejs). Contributions are welcome.
6868

69-
+ `__test__/test_data/schema.k`
69+
* `__test__/test_data/schema.k`
7070

7171
```python
7272
schema AppConfig:
@@ -77,39 +77,43 @@ app: AppConfig {
7777
}
7878
```
7979

80-
+ `execProgram`
80+
- `execProgram`
8181

8282
```ts
8383
import { execProgram, ExecProgramArgs } from "kcl-lib";
8484

8585
function main() {
8686
const result = execProgram(ExecProgramArgs(["__test__/test_data/schema.k"]));
87-
console.log(result.yamlResult); // 'app:\n replicas: 2'
87+
console.log(result.yamlResult); // 'app:\n replicas: 2'
8888
}
8989

9090
main();
9191
```
9292

93-
+ `listVariables`
93+
- `listVariables`
9494

9595
```ts
9696
import { listVariables, ListVariablesArgs } from "kcl-lib";
9797

9898
function main() {
99-
const result = listVariables(ListVariablesArgs('__test__/test_data/schema.k', []))
100-
console.log(result.variables['app'].value); // 'AppConfig {replicas: 2}'
99+
const result = listVariables(
100+
ListVariablesArgs("__test__/test_data/schema.k", []),
101+
);
102+
console.log(result.variables["app"].value); // 'AppConfig {replicas: 2}'
101103
}
102104

103105
main();
104106
```
105107

106-
+ `loadPackage`
108+
- `loadPackage`
107109

108110
```ts
109111
import { loadPackage, LoadPackageArgs } from "kcl-lib";
110112

111113
function main() {
112-
const result = loadPackage(LoadPackageArgs(['__test__/test_data/schema.k'], [], true));
114+
const result = loadPackage(
115+
LoadPackageArgs(["__test__/test_data/schema.k"], [], true),
116+
);
113117
console.log(result.symbols);
114118
}
115119

docs/tools/cli/kcl/docgen.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Refer to [reST](https://docutils.sourceforge.io/rst.html) for more information.
9595
### kcl doc
9696

9797
```shell
98-
This command shows documentation for KCL package or symbol.
98+
This command shows documentation for KCL modules or symbols.
9999

100100
Usage:
101101
kcl doc [command]
@@ -107,7 +107,6 @@ Examples:
107107
# Generate document for current package
108108
kcl doc generate
109109

110-
111110
Available Commands:
112111
generate Generates documents from code and examples
113112

@@ -120,6 +119,8 @@ Use "kcl doc [command] --help" for more information about a command.
120119
### kcl doc generate
121120

122121
```shell
122+
This command generates documents for KCL modules.
123+
123124
Usage:
124125
kcl doc generate [flags]
125126

@@ -139,7 +140,6 @@ Examples:
139140
# Generate Markdown document for specific package to a <target directory>
140141
kcl doc generate --file-path <package path> --target <target directory>
141142

142-
143143
Flags:
144144
--escape-html Whether to escape html symbols when the output format is markdown. Always scape when the output format is html. Default to false.
145145
--file-path string Relative or absolute path to the KCL package root when running kcl-doc command from

docs/tools/cli/kcl/lint.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ Examples:
5353
kcl lint path/to/kcl1.k path/to/kcl2.k
5454

5555
# Lint OCI packages
56-
kcl lint oci://ghcr.io/kcl-lang/hello-world
56+
kcl lint oci://ghcr.io/kcl-lang/helloworld
5757

5858
# Lint the current package
5959
kcl lint
6060

61-
6261
Flags:
63-
-D, --argument strings Specify the top-level argument
62+
-D, --argument stringArray Specify the top-level argument
6463
-d, --debug Run in debug mode
6564
-n, --disable_none Disable dumping None values
6665
-E, --external strings Specify the mapping of package name and path where the package is located
@@ -72,6 +71,7 @@ Flags:
7271
-S, --path_selector strings Specify the path selectors
7372
-q, --quiet Set the quiet mode (no output)
7473
-Y, --setting strings Specify the command line setting files
74+
-H, --show_hidden Display hidden attributes
7575
-k, --sort_keys Sort output result keys
7676
-r, --strict_range_check Do perform strict numeric range checks
7777
-t, --tag string Specify the tag for the OCI or Git artifact

docs/tools/cli/kcl/overview.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ KCL toolchain is a toolset of KCL language, which aims to improve the efficiency
2727
## Args
2828

2929
```shell
30+
The KCL Command Line Interface (CLI).
31+
32+
KCL is an open-source, constraint-based record and functional language that
33+
enhances the writing of complex configurations, including those for cloud-native
34+
scenarios. The KCL website: https://kcl-lang.io
35+
3036
Usage:
3137
kcl [command]
3238

@@ -35,8 +41,9 @@ Available Commands:
3541
completion Generate the autocompletion script for the specified shell
3642
doc KCL document tool
3743
fmt KCL format tool
44+
help Help about any command
3845
import KCL import tool
39-
lint Run KCL codes.
46+
lint Lint KCL codes.
4047
mod KCL module management
4148
play Open the kcl playground in the browser.
4249
registry KCL registry management
@@ -50,8 +57,5 @@ Flags:
5057
-h, --help help for kcl
5158
-v, --version version for kcl
5259

53-
Additional help topics:
54-
kcl
55-
5660
Use "kcl [command] --help" for more information about a command.
5761
```

docs/tools/cli/kcl/run.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ This command runs the kcl code and displays the output. 'kcl run' takes multiple
99
## Args
1010

1111
```shell
12+
This command runs the kcl code and displays the output. 'kcl run' takes multiple input for arguments.
13+
14+
For example, 'kcl run path/to/kcl.k' will run the file named path/to/kcl.k
15+
1216
Usage:
1317
kcl run [flags]
1418

@@ -26,14 +30,16 @@ Examples:
2630
kcl run path/to/kcl1.k path/to/kcl2.k
2731

2832
# Run OCI packages
29-
kcl run oci://ghcr.io/kcl-lang/hello-world
33+
kcl run oci://ghcr.io/kcl-lang/helloworld
34+
35+
# Run remote Git repo
36+
kcl run https://github.com/kcl-lang/flask-demo-kcl-manifests
3037

3138
# Run the current package
3239
kcl run
3340

34-
3541
Flags:
36-
-D, --argument strings Specify the top-level argument
42+
-D, --argument stringArray Specify the top-level argument
3743
-d, --debug Run in debug mode
3844
-n, --disable_none Disable dumping None values
3945
-E, --external strings Specify the mapping of package name and path where the package is located
@@ -45,6 +51,7 @@ Flags:
4551
-S, --path_selector strings Specify the path selectors
4652
-q, --quiet Set the quiet mode (no output)
4753
-Y, --setting strings Specify the command line setting files
54+
-H, --show_hidden Display hidden attributes
4855
-k, --sort_keys Sort output result keys
4956
-r, --strict_range_check Do perform strict numeric range checks
5057
-t, --tag string Specify the tag for the OCI or Git artifact
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# kcl mod graph
2+
3+
Print the module dependency graph. Each module is identified as a string of the form path@version.
4+
5+
## Usage
6+
7+
```shell
8+
kcl mod graph [flags]
9+
```
10+
11+
## Description
12+
13+
`kcl mod graph` will print the module dependency graph. Each module is identified as a string of the form path@version.
14+
15+
## Options
16+
17+
### --help, -h
18+
19+
Show help for `kcl mod graph` command.
20+
21+
## Examples
22+
23+
### Print the current module dependency graph.
24+
25+
```shell
26+
kcl mod graph
27+
```

docs/user_docs/support/faq-kcl.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,34 +2539,34 @@ The above KCL code gives the output:
25392539

25402540
```yaml
25412541
final_list:
2542-
- 1
2543-
- 2
2544-
- 3
2545-
- 4
2546-
- 5
2547-
- 6
2542+
- 1
2543+
- 2
2544+
- 3
2545+
- 4
2546+
- 5
2547+
- 6
25482548
```
25492549

25502550
## 61. What does `version: "v1" = "v1"` mean?
25512551

25522552
The first `"v1"` over here denotes that the type of the variable `version` is of string literal type. The second `"v1"` denotes that the default value of the variable `version` is `"v1"`.
25532553

2554-
## 62. How do i define a schema to verify the contents of a given JSON file?
2554+
## 62. How to define a schema to verify the contents of a given JSON file?
25552555

2556-
We can use the kcl `vet` tool to validate the JSON data in a given JSOn file. For example, in the below data.json file we use the KCL file(schema.k) below to validate the `age` parameter.
2556+
We can use the kcl `vet` tool to validate the JSON data in a given JSOn file. For example, in the below data.json file we use the KCL file(schema.k) below to validate the `age` parameter.
25572557

25582558
data.json
25592559

25602560
```json
25612561
[
2562-
{
2563-
"name": "Alice",
2564-
"age": 18
2565-
},
2566-
{
2567-
"name": "Bob",
2568-
"age": 10
2569-
}
2562+
{
2563+
"name": "Alice",
2564+
"age": 18
2565+
},
2566+
{
2567+
"name": "Bob",
2568+
"age": 10
2569+
}
25702570
]
25712571
```
25722572

@@ -2583,7 +2583,6 @@ schema Person:
25832583

25842584
The command to validate the JSON data below gives the output `Validate success!`.
25852585

2586-
```bash
2586+
```bash
25872587
kcl vet data.json schema.k
25882588
```
2589-

i18n/zh-CN/docusaurus-plugin-content-blog/2024-04-17-newsletter/index.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ cargo add --git https://github.com/kcl-lang/lib
6666

6767
- KCL Node.js SDK 初版发布,仓库地址 [https://github.com/kcl-lang/lib/tree/main/nodejs](https://github.com/kcl-lang/lib/tree/main/nodejs), 欢迎共建
6868

69-
+ `__test__/test_data/schema.k`
69+
* `__test__/test_data/schema.k`
7070

7171
```python
7272
schema AppConfig:
@@ -77,39 +77,43 @@ app: AppConfig {
7777
}
7878
```
7979

80-
+ `execProgram`
80+
- `execProgram`
8181

8282
```ts
8383
import { execProgram, ExecProgramArgs } from "kcl-lib";
8484

8585
function main() {
8686
const result = execProgram(ExecProgramArgs(["__test__/test_data/schema.k"]));
87-
console.log(result.yamlResult); // 'app:\n replicas: 2'
87+
console.log(result.yamlResult); // 'app:\n replicas: 2'
8888
}
8989

9090
main();
9191
```
9292

93-
+ `listVariables`
93+
- `listVariables`
9494

9595
```ts
9696
import { listVariables, ListVariablesArgs } from "kcl-lib";
9797

9898
function main() {
99-
const result = listVariables(ListVariablesArgs('__test__/test_data/schema.k', []))
100-
console.log(result.variables['app'].value); // 'AppConfig {replicas: 2}'
99+
const result = listVariables(
100+
ListVariablesArgs("__test__/test_data/schema.k", []),
101+
);
102+
console.log(result.variables["app"].value); // 'AppConfig {replicas: 2}'
101103
}
102104

103105
main();
104106
```
105107

106-
+ `loadPackage`
108+
- `loadPackage`
107109

108110
```ts
109111
import { loadPackage, LoadPackageArgs } from "kcl-lib";
110112

111113
function main() {
112-
const result = loadPackage(LoadPackageArgs(['__test__/test_data/schema.k'], [], true));
114+
const result = loadPackage(
115+
LoadPackageArgs(["__test__/test_data/schema.k"], [], true),
116+
);
113117
console.log(result.symbols);
114118
}
115119

i18n/zh-CN/docusaurus-plugin-content-docs/current/tools/cli/kcl/docgen.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ kcl doc generate --file-path <package path> --target <target directory>
9595
### kcl doc
9696

9797
```shell
98-
This command shows documentation for KCL package or symbol.
98+
This command shows documentation for KCL modules or symbols.
9999

100100
Usage:
101101
kcl doc [command]
@@ -107,7 +107,6 @@ Examples:
107107
# Generate document for current package
108108
kcl doc generate
109109

110-
111110
Available Commands:
112111
generate Generates documents from code and examples
113112

@@ -120,6 +119,8 @@ Use "kcl doc [command] --help" for more information about a command.
120119
### kcl doc generate
121120

122121
```shell
122+
This command generates documents for KCL modules.
123+
123124
Usage:
124125
kcl doc generate [flags]
125126

@@ -139,7 +140,6 @@ Examples:
139140
# Generate Markdown document for specific package to a <target directory>
140141
kcl doc generate --file-path <package path> --target <target directory>
141142

142-
143143
Flags:
144144
--escape-html Whether to escape html symbols when the output format is markdown. Always scape when the output format is html. Default to false.
145145
--file-path string Relative or absolute path to the KCL package root when running kcl-doc command from

i18n/zh-CN/docusaurus-plugin-content-docs/current/tools/cli/kcl/lint.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ Examples:
5353
kcl lint path/to/kcl1.k path/to/kcl2.k
5454

5555
# Lint OCI packages
56-
kcl lint oci://ghcr.io/kcl-lang/hello-world
56+
kcl lint oci://ghcr.io/kcl-lang/helloworld
5757

5858
# Lint the current package
5959
kcl lint
6060

61-
6261
Flags:
63-
-D, --argument strings Specify the top-level argument
62+
-D, --argument stringArray Specify the top-level argument
6463
-d, --debug Run in debug mode
6564
-n, --disable_none Disable dumping None values
6665
-E, --external strings Specify the mapping of package name and path where the package is located
@@ -72,6 +71,7 @@ Flags:
7271
-S, --path_selector strings Specify the path selectors
7372
-q, --quiet Set the quiet mode (no output)
7473
-Y, --setting strings Specify the command line setting files
74+
-H, --show_hidden Display hidden attributes
7575
-k, --sort_keys Sort output result keys
7676
-r, --strict_range_check Do perform strict numeric range checks
7777
-t, --tag string Specify the tag for the OCI or Git artifact

0 commit comments

Comments
 (0)