2 Star 0 Fork 0

AutoM Studio / punch

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

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

About

通过 go template 格式的模板文件生成目标配置文件。 expand collapse
Go
Apache-2.0
Cancel

Releases (1)

All

Contributors

All

Activities

Load More
can not load any more
1
https://gitee.com/autom-studio/punch.git
git@gitee.com:autom-studio/punch.git
autom-studio
punch
punch
master

Search