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.0.tar.gz (2.6 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.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: generate_env_sample-0.1.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for generate_env_sample-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee23a8f357f4559ac1e1b8ce673a3790deead1089672cfa3e088cf5a447b8998
MD5 522ad4a795d4c143e0f6beb08f361bab
BLAKE2b-256 3be0f51f2bd8f12010fad5dfc057367ed655d832eb3a2606956613f20eb03b7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for generate_env_sample-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 015df04c3cfcc76a584455b23d116e5f72c2b5a80016a56e0ae6c12400f0b6c3
MD5 210e5ac93b29f0ccfdb3336807a6cffa
BLAKE2b-256 2bcd482eef1cfdef8bc76fc97192a93766ddc7c12db4ba1c2ae036a12322369a

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