kcl-lang.io/kpm@v0.8.7-0.20240520061008-9fc4c5efc8c7/docs/command-reference/11.import.md (about) 1 # kpm import 2 3 Convert files in other formats to kcl files. 4 5 ## Usage 6 7 ```shell 8 kpm import [options] <file> 9 ``` 10 11 ## Description 12 13 `kpm import` reads content from the specified file and converts it into a kcl file. 14 15 ## Options 16 17 ### --mode, -m 18 19 Specify the conversion mode. Default value is `auto`. The following modes are supported: 20 21 - `json`: Convert json data to kcl data. 22 - `yaml`: Convert yaml data to kcl data. 23 - `gostruct`: Convert go structures to kcl schema. 24 - `jsonschema`: Convert json schema to kcl schema. 25 - `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). 26 - `auto`: Automatically detect the file type and use the corresponding conversion mode. 27 28 ### --output, -o 29 30 Specify the output file name. Default value is `generated.k`. 31 32 ### --force, -f 33 34 Force overwrite of the output file. 35 36 ### --help, -h 37 38 Display help information for the `kpm import` command. 39 40 ## Examples 41 42 Use `kpm import` to convert yaml data to kcl data. 43 44 ``` 45 $ cat <<EOF > foo.yaml 46 kind: Service 47 name: kcl 48 EOF 49 50 $ kpm import foo.yaml 51 52 $ cat generated.k 53 """ 54 This file was generated by the KCL auto-gen tool. DO NOT EDIT. 55 Editing this file might prove futile when you re-run the KCL auto-gen generate command. 56 """ 57 58 kind = "Service" 59 name = "kcl" 60 ```