envtpl

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 11 Imported by: 0

README

envtpl

A CLI tool for generating .env files from .env.template files via prompts and random values.

Usage

envtpl [template-file] -o [output-file]
Supported types
# .env.template
UUID=<uuid>
PASSWORD=<alpha:24>
ENCRYPTION_KEY=<ascii85:32>
ENCRYPTION_IV=<base64:16>
ENCRYPTION_SALT=<hex:16>
PORT=<int:1-65535>
ENUM=<enum:development,production>
PROMPT=<text:Enter your name>
SECRET_PROMPT=<password:Enter your password>
PROMPT_2= # Empty values elicit a prompt
Type Description Example
alpha Random alphanumeric characters PASSWORD=<alpha:24>
ascii85 Random ASCII characters ENCRYPTION_KEY=<ascii85:32>
base64 Random base64 characters ENCRYPTION_IV=<base64:16>
hex Random hexadecimal characters ENCRYPTION_SALT=<hex:16>
uuid Random UUIDv4 UUID=<uuid>
enum Enumerated list of values ENUM=<enum:development,production>
int Random integer PORT=<int:1-65535>
text Prompt user for text input PROMPT1=<text:Enter your name>
password Prompt user for secret input SECRET_PROMPT=<password:Enter your API key>

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidArg = errors.New("invalid argument")
)

Functions

This section is empty.

Types

type EnvValue

type EnvValue struct {
	Type ValueType
	// contains filtered or unexported fields
}

func ParseValue

func ParseValue(value string) *EnvValue

func (*EnvValue) Generate

func (v *EnvValue) Generate() (interface{}, error)

type EnvVar

type EnvVar struct {
	Key   string
	Value *EnvValue
}

func Parse

func Parse(file string) ([]EnvVar, error)

type ValueType

type ValueType string
const (
	Plain    ValueType = "plain"
	Text     ValueType = "text"
	Password ValueType = "password"
	Enum     ValueType = "enum"
	UUID     ValueType = "uuid"
	Alpha    ValueType = "alpha"
	Hex      ValueType = "hex"
	Base64   ValueType = "base64"
	Ascii85  ValueType = "ascii85"
	Int      ValueType = "int"
)

Directories

Path Synopsis
cmd
envtpl command
pkg
nanoid
Credit: https://github.com/matoous/go-nanoid Credit: https://github.com/ai/nanoid
Credit: https://github.com/matoous/go-nanoid Credit: https://github.com/ai/nanoid

Jump to

Keyboard shortcuts

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