From 60a598daef1c86719780ae195d15bd04419cd108 Mon Sep 17 00:00:00 2001 From: jakezhu9 Date: Sat, 23 Sep 2023 17:49:54 +0800 Subject: [PATCH] docs: add docs for kpm import Signed-off-by: jakezhu9 --- docs/command-reference-zh/11.import.md | 60 ++++++++++++++++++++++++++ docs/command-reference/11.import.md | 60 ++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 docs/command-reference-zh/11.import.md create mode 100644 docs/command-reference/11.import.md diff --git a/docs/command-reference-zh/11.import.md b/docs/command-reference-zh/11.import.md new file mode 100644 index 00000000..33ebca04 --- /dev/null +++ b/docs/command-reference-zh/11.import.md @@ -0,0 +1,60 @@ +# kpm import + +将其它格式的文件转换为 kcl 文件。 + +## 使用 + +```shell +kpm import [options] +``` + +## 介绍 + +`kpm import` 会从指定的文件中读取内容,并将其转换为 kcl 文件。 + +## 选项 + +### --mode, -m + +指定转换模式,默认值为 `auto`,以下是支持的模式: + +- `json`: 将 json 数据转换为 kcl 数据。 +- `yaml`: 将 yaml 数据转换为 kcl 数据。 +- `gostruct`: 将 go 结构体转换为 kcl schema。 +- `jsonschema`: 将 json schema 转换为 kcl schema。 +- `terraformschema`: 将 terraform provider schema 转换为 kcl schema。关于如何获取 terraform provider schema 文件,请参考 [terraform schema](https://developer.hashicorp.com/terraform/cli/commands/providers/schema)。 +- `auto`: 自动检测文件类型,并使用对应的转换模式。 + +### --output, -o + +指定输出文件名,默认值为 `generated.k`。 + +### --force, -f + +强制覆盖输出文件。 + +### --help, -h + +展示 `kpm import` 命令的帮助信息。 + +## 示例 + +使用 `kpm import` 将 yaml 数据转换为 kcl 数据。 + +``` +$ cat < foo.yaml +kind: Service +name: kcl +EOF + +$ kpm import foo.yaml + +$ cat generated.k +""" +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + +kind = "Service" +name = "kcl" +``` diff --git a/docs/command-reference/11.import.md b/docs/command-reference/11.import.md new file mode 100644 index 00000000..b751151b --- /dev/null +++ b/docs/command-reference/11.import.md @@ -0,0 +1,60 @@ +# kpm import + +Convert files in other formats to kcl files. + +## Usage + +```shell +kpm import [options] +``` + +## Description + +`kpm import` reads content from the specified file and converts it into a kcl file. + +## Options + +### --mode, -m + +Specify the conversion mode. Default value is `auto`. The following modes are supported: + +- `json`: Convert json data to kcl data. +- `yaml`: Convert yaml data to kcl data. +- `gostruct`: Convert go structures to kcl schema. +- `jsonschema`: Convert json schema to kcl schema. +- `terraformschema`: Convert terraform provider schema to kcl schema. For how to obtain terraform provider schema files, refer to [terraform schema](https://developer.hashicorp.com/terraform/cli/commands/providers/schema). +- `auto`: Automatically detect the file type and use the corresponding conversion mode. + +### --output, -o + +Specify the output file name. Default value is `generated.k`. + +### --force, -f + +Force overwrite of the output file. + +### --help, -h + +Display help information for the `kpm import` command. + +## Examples + +Use `kpm import` to convert yaml data to kcl data. + +``` +$ cat < foo.yaml +kind: Service +name: kcl +EOF + +$ kpm import foo.yaml + +$ cat generated.k +""" +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + +kind = "Service" +name = "kcl" +``` \ No newline at end of file