Menu

Tree [982f6c] master v0.1.4 /
 History

HTTPS access


File Date Author Commit
 .github 2021-07-11 Khaliq Khaliq [a5640c] fix: license info
 cmd 2021-07-13 kha7iq kha7iq [43b5d8] feat: preserve folder & file structure
 docs 2021-07-13 kha7iq kha7iq [651d7c] docs: update docs for ouput folder
 examples 2021-07-09 khaliq khaliq [3eef79] chore: add example files
 .gitignore 2021-07-06 khaliq khaliq [e3ec1d] chore: add gitignore file
 .golangci.yml 2021-07-06 khaliq khaliq [ef8116] feat: add golang linters
 .goreleaser.yaml 2021-07-11 kha7iq kha7iq [924e48] fix: move publish custom package step
 CODE_OF_CONDUCT.md 2021-07-06 khaliq khaliq [68c181] docs: add code of conduct
 CONTRIBUTING.md 2021-07-08 khaliq khaliq [bd1a05] docs: add documentation testing details
 Dockerfile 2021-07-07 khaliq khaliq [e3d9a3] feat: add docker file
 LICENSE.md 2021-07-07 khaliq khaliq [015813] docs: change license file to markdown
 Makefile 2021-07-06 khaliq khaliq [ac0b28] chore: add make file
 README.md 2021-07-13 kha7iq kha7iq [651d7c] docs: update docs for ouput folder
 go.mod 2021-07-07 khaliq khaliq [23938f] chore: update sprig dep
 go.sum 2021-07-07 khaliq khaliq [23938f] chore: update sprig dep
 main.go 2021-07-10 khaliq khaliq [698145] fix: lint and fmt code
 mkdocs.yml 2021-07-08 khaliq khaliq [cccdb5] feat: add documentation

Read Me


Release Go Report Card Build GitHub issues License Go Dev Reference

DocumentationInstallationConfigurationContributingShow Your Support


About

Substitute Variables (subvars) is a small utility which provides a way to render any Go templates
from command line recognizing the object being passed in and drawing attributes from the object to create wanted text.
It is very useful for template driven configuration files.

It uses sprig v3 for template functions
which provides additional functions apart from standard library.

subvars reads input from stdin and renders output to stdout.
You can pipe the input or < direct it to subvars.

Options to render all files in a given folder
and output to another folder preserving folder and file structure is available via dir subcommand.

Installation

MacOS & Linux Homebrew

brew install kha7iq/tap/subvars

Linux

  • AUR
yay -S subvars
  • Binary
export SUBVARS_VERSION="0.1.2"
wget -q https://github.com/kha7iq/subvars/releases/download/v${SUBVARS_VERSION}/subvars_Darwin_x86_64.tar.gz && \
tar -xf subvars_Darwin_x86_64.tar.gz && \
chmod +x subvars && \
sudo mv subvars /usr/local/bin/subvars

Windows

scoop bucket add subvars https://github.com/kha7iq/scoop-bucket.git
scoop install subvars

Alternatively you can head over to release pages
and download the binary for windows & all other supported platforms.

Docker

Docker container is available you can pull the latest version or provide specific tag
Checkout release page for available versions.

Running Container

docker pull khaliq/subvars:latest

docker run -it --rm khaliq/subvars:latest --help

Usage

 subvars --help

NAME:
   subvars - Substitute environment variables defined as go templates.

USAGE:
   subvars [global options] command [command options] [arguments...]

VERSION:
   0.1.2

COMMANDS:
   dir, d   Directory lets you render all files in a folder & subfolder.
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --prefix value, --pr value    Match only variables with given prefix pattern [$SUBVARS_PREFIX]
   --missingkey value, -m value  Behavior for missing key when parsing variables. Available options 'invalid', 'error' or 'zero' (default: "invalid") [$SUBVARS_MISSINGKEY]
   --help, -h                    show help (default: false)
   --version, -v                 print the version (default: false)
echo "Hey! {{ .USER | upper }} your home folder is {{ .HOME }}" | subvars
subvars dir --input examples --out conf

Check Usage Documentation for detailed examples.

Configuration

All the flags have corresponding environment variables associated with it. You
can either provide the value with flags or export to a variable.

View the Configuration Page for more
details.

Contributing

Contributions, issues and feature requests are most welcome!
Feel free to check
issues page. You can also take a look
at the contributing guide.

Show your support

Give a ⭐️ if you like this project!

Fork it ⚙️

Make it better 🕶️

Acknowledgments

This tool was inspired by the original python envtpl
project and subfuzion