Skip to content

homburg/envoke

Repository files navigation

Envoke

Build Status

envoke is for templating a file from environment variables with whatever delimiters you could want.

Template syntax

envoke uses Go's text/template package for templating. All environment variables are converted to template "functions", ie. {{ API_KEY }}

Usage

# somefile.go.src
$ echo "
somefile.go.src

package main

const API_KEY = {{ API_KEY }}

func main () {
	
}" > somefile.go.src

# envoke!
$ API_KEY=xkembiy envoke somefile.go.src > somefile.go


# Use your own delimiters:
# somefile.html.src
$ echo "<html>
<head>
	<script type="text/javascript">
	  window.API_KEY = [[ API_KEY ]];
	</script>
</head>
<body>
	<h1>{{ hello }} angular!</h1>
</body>
</html>" > somefile.html

$ API_KEY=seeeecret envoke "[[" "]]" somefile.html.src > somefile.html


# Fail on missing variables
$ envoke "[[" "]]" somefile.html || echo 'Nope!'
# ->
# Nope!

# or not
$ envoke -f "[[" "]]" somefile.html || echo 'Nope!'
# ->
# <head>
# ...


# Envoke from stdin
$ cat "Go {{ HOME }}" | envoke

TODO

  • Stdin
  • Non-strict/force mode
  • Test for
    • Fail on strict mode
    • Help message

About

Envoke - template files with environment variables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages