Skip to main content

A simple CLI tool to generate .env.sample files from existing .env files, preserving comments and empty lines.

Project description

Generate-Env-Sample

PyPI version

A simple CLI tool to generate .env.sample files from existing .env files. This tool reads your .env file, preserves comments and empty lines, and creates a sample file with keys but without values.

Features

  • Preserves comments and empty lines from the original .env file.
  • Generates a clean .env.sample with keys set to empty values.
  • Handles encoding issues, permissions, and file existence gracefully.
  • Built with Python and Typer for a smooth CLI experience.

Installation

You can install using one of the following methods:

  • Using pipx:
    pipx install generate-env-sample
    
  • Using uv:
    uv tool install generate-env-sample
    
  • Run directly with pipx:
    pipx run generate-env-sample
    
  • Run directly with uvx:
    uvx generate-env-sample
    

Prerequisites

  • Python 3.11 or higher

Build Instructions

This project uses uv for management. To build the project, follow these steps:

  1. Install uv by following the uv documentation.

  2. Clone the repository:

    git clone https://github.com/heshinth/generate-env-sample.git
    cd generate-env-sample
    
  3. Sync the project dependencies using uv sync:

    uv sync
    

Usage

Run the tool from the command line:

generate-env-sample

Options

  • --file: Specify the .env file to read from (default: .env)
  • --sample: Specify the output .env.sample file (default: .env.sample)

Examples

  1. Generate .env.sample from the default .env:

    generate-env-sample
    
  2. Use a custom .env file:

    generate-env-sample --file myenv.env --sample myenv.sample
    
  3. Get help:

    generate-env-sample --help
    

Example Input/Output

Given a .env file like:

# Database configuration
DB_HOST=localhost
DB_PORT=5432

# API keys
API_KEY=your_secret_key

The generated .env.sample will be:

# Database configuration
DB_HOST=
DB_PORT=

# API keys
API_KEY=

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

generate_env_sample-0.1.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

generate_env_sample-0.1.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file generate_env_sample-0.1.2.tar.gz.

File metadata

  • Download URL: generate_env_sample-0.1.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for generate_env_sample-0.1.2.tar.gz
Algorithm Hash digest
SHA256 614982ac119790b1749afd18cbb83f4ea4beb09c11ceb3d93afaa8676692822b
MD5 f8063f1db8ca2d838681e404930dadb1
BLAKE2b-256 a1bf177145d2688439d6d3cc9d27853627c854786fbeb8642aa6f2f4e2261f3a

See more details on using hashes here.

File details

Details for the file generate_env_sample-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: generate_env_sample-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for generate_env_sample-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d87caf07027d4d02d0ca77a8ca5699f21f486284bd58ec37ef90cf6ff7c3f147
MD5 1dad67e8e1e5f188b65dc9f5615d2ba6
BLAKE2b-256 cf6f56abf3a77ed2d1d50abd9ff0bbcb07bcc03c0ff514eb3cd8868c96be9e63

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page