envprof

command module
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 2 Imported by: 0

README

envprof logo

envprof

Profile-based environment variable manager


GitHub release Go Reference Go Report Card Build Status

envprof is a CLI tool for managing named environment profiles in YAML or TOML. It supports layering (inheritance) of profiles and is designed for clarity and shell integration.

Features

  • Define multiple environment profiles in one file
  • Supports YAML and TOML formats
  • Profile inheritance with conflict resolution
  • Export profiles to shell using eval "$(envprof export <profile>)"
  • Export profiles to .env files

Installation

For a quick installation, you can use the provided installation script:

curl -sSL https://raw.githubusercontent.com/idelchi/envprof/refs/heads/dev/install.sh | sh -s -- -d ~/.local/bin

Usage

# list all profiles
envprof list

# list all variables in a profile
envprof list dev

# list a specific variable
envprof list dev DB_URL

# export for shell eval
eval "$(envprof export dev)"

# export profile to a file
envprof export dev .env

The following flags are available:

  • --file, -f: Specify a file (or list of fallbacks) to load. Defaults to ENVPROF_FILE or envprof.yaml, envprof.yml, envprof.toml.
  • --verbose, -v: Enable verbose output to trace inheritance for variables.

Format

Complex types (arrays, maps) are serialized as JSON representations, everything else is stringified.

YAML

dev:
  extends:
    - staging
  env:
    HOST: localhost

staging:
  extends:
    - prod
  env:
    HOST: staging.example.com
    DEBUG: true

prod:
  env:
    HOST: prod.example.com
    PORT: 80
    DEBUG: false

TOML

[dev]
extends = ['staging']
[dev.env]
HOST = 'localhost'

[staging]
extends = ['prod']
[staging.env]
DEBUG = true
HOST = 'staging.example.com'

[prod.env]
DEBUG = false
HOST = 'prod.example.com'
PORT = 80

Inheritance Behavior

Inheritance is resolved in order. Later profiles override earlier ones. As an example, running envprof export dev .env with the previous YAML file produces the following .env file:

# Active profile: "dev"
HOST=localhost
DEBUG=true
PORT=80

Inspecting with envprof list dev -v would show the inheritance chain:

HOST=localhost
DEBUG=true                                    (inherited from "staging")
PORT=80                                       (inherited from "prod")

Additional commands

Below commands are destructive (reformat the profiles file) and should just be used to set up the initial file if you care about comments and formatting.

# import values from a dotenv file into a profile (creating it if it doesn't exist),
# with the option whether to keep existing values in case of conflicts or to overwrite them
envprof import dev [--keep] .env

# convert current file to another format
envprof convert [yaml|toml]

Documentation

Overview

Command envprof is a command-line tool for managing environment variables in profiles.

Directories

Path Synopsis
internal
cli
Package cli implements the command-line interface for envprof.
Package cli implements the command-line interface for envprof.
profile
Package profile provides profile and store management for environment variable sets.
Package profile provides profile and store management for environment variable sets.

Jump to

Keyboard shortcuts

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