Fetch the repository succeeded.
一个根据 go template 格式的模板配置文件生成目标配置文件的小工具。
git clone https://gitee.com/autom-studio/punch
cd punch
go build -o examples/punch
准备模板配置文件,格式如文件: 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
> ./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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。