From 30c0b3a64bc611885dbca54f190720f51069933e Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Mon, 13 Nov 2023 12:01:31 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=B7=A5=E5=85=B7=E9=83=A8=E5=88=86=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/README.md b/README.md index 527cc4c..0f46bae 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,80 @@ func main() { - 模板文件图例: ![exporter-xlsx-template.png](.github/images/exporter-xlsx-template.png) +#### 导出 JSON 文件(可供客户端直接使用,包含索引的配置导出后为键值模式,可直接读取) +```text +Flags: + -e, --exclude string excluded configuration names or display names (comma separated) | 排除的配置名或显示名(英文逗号分隔) + -h, --help help for json + -o, --output string directory path of the output json file | 输出的 json 文件所在目录路径 + -p, --prefix string export configuration file name prefix | 导出配置文件名前缀 + -t, --type string export server configuration[s] or client configuration[c] | 导出服务端配置[s]还是客户端配置[c] + -f, --xlsx string xlsx file path or directory path | xlsx 文件路径或所在目录路径 + +``` +```shell +expoter.exe json -t s -f xlsx_template.xlsx -o ./output +``` +导出结果示例 +```json +{ + "1": { + "b": { + "Id": 1, + "Count": "b", + "Info": { + "id": 1, + "name": "小明", + "info": { + "lv": 1, + "exp": { + "mux": 10, + "count": 100 + } + } + }, + "Other": [ + { + "id": 1, + "name": "张飞" + }, + { + "id": 2, + "name": "刘备" + } + ] + } + } +} + +``` + +#### 导出 Golang 文件 +```text +Flags: + -e, --exclude string excluded configuration names or display names (comma separated) | 排除的配置名或显示名(英文逗号分隔) + -h, --help help for go + -o, --output string output path | 输出的 go 文件路径 + -f, --xlsx string xlsx file path or directory path | xlsx 文件路径或所在目录路径 +``` +```shell +expoter.exe go -f xlsx_template.xlsx -o ./output +``` +使用示例 + +```go +package main + +import ( + "fmt" + "config" +) + +func main() { + fmt.Println(config.EasyConfig.Id) +} +``` + ### 持续更新的示例项目 - **[Minotaur-Example](https://github.com/kercylan98/minotaur-example)**