# punch **Repository Path**: autom-studio/punch ## Basic Information - **Project Name**: punch - **Description**: 通过 go template 格式的模板文件生成目标配置文件。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-03-10 - **Last Updated**: 2024-04-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Punch 一个根据 go template 格式的模板配置文件生成目标配置文件的小工具。 ## Build ``` git clone https://gitee.com/autom-studio/punch cd punch go build -o examples/punch ``` ## Usage + 准备模板配置文件,格式如文件: `examples/template.conf.tmpl` 所示 + 准备 `key: value` 配置文件,用于定义模板配置文件中每个键的值,格式支持 `toml/yaml/json` 格式,示例见文件: `examples/items.toml` / `examples/items.yaml` / `examples/items.json` + 执行命令,生成目标配置文件 ``` > ./punch -h A tool for generating a configuration file from a template file. Punch can load variables from json/yaml/toml format file, then replace the template file with these variables to generate the final configuration file. Usage: punch [flags] Flags: -d, --dest string save output to dest file, default is ./template.conf (default "./template.conf") --dryrun just output result to console instead of destination file, default is false -e, --env load system environments, default is false -h, --help help for punch -i, --items string items file, default is ./items.toml (default "./items.toml") -t, --template string configured template file, default is ./template.conf.tmpl (default "./template.conf.tmpl") -v, --version version for punch ``` ### Example ``` > ./punch -e -i items.toml -t template.conf.tmpl --dryrun { "domain": "gitee.com", "port": 80, "smtp": { "server": "smtp.gitee.com", "port": 25 }, "home": "", "user": "atompi" } domain = "gitee.com" port = 80 {"port":25,"server":"smtp.gitee.com"} domain: gitee.com port: 80 ```