envoke

command module
v0.0.0-...-c3c1118 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2014 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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

Documentation

Overview

Envoke

Fill template from environment variable Usage:

  # Fill with default template syntax and print to stdout
  envoke template.file

  # Fill with alternative delimiters and print to stdout
	 envoke '<<' '>>' template.file

  # Fill template from stdin
  envoke

  # Fill template from stdin
  envoke -

  # Fill with alternative template delimiters from stdin
  envoke '<<' '>>' -
  envoke '<<' '>>'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址