Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Generator Example

This example demonstrates all metadata annotations supported by the zenv generate command.

Structure

generator/
├── .env.example    # Annotated environment variables
└── README.md

Run the Generator

# Preview without writing (dry run)
./target/release/zenv generate --dry-run examples/generator

# Non-interactive mode (for CI/CD)
./target/release/zenv generate --dry-run --non-interactive examples/generator

# Actually generate the .env file
./target/release/zenv generate examples/generator

# Force overwrite existing .env
./target/release/zenv generate --force examples/generator

Metadata Annotations

The .env.example file demonstrates all available annotations:

@required (default)

Variable must have a value. This is the default behavior.

# @required
LOG_LEVEL=info

@optional

Variable can be skipped during generation.

# @optional
ANALYTICS_ID=

@prompt "description"

Prompts the user to enter a value interactively.

# @required @prompt "PostgreSQL connection string"
DATABASE_URL=

@generate <length>

Auto-generates a cryptographically secure base64 secret.

# @required @generate 32
JWT_SECRET=

# @optional @generate 64
ENCRYPTION_KEY=

Combining Annotations

Annotations can be combined:

# @optional @generate 32
WEBHOOK_SECRET=

# @required @prompt "Enter your Stripe secret key"
STRIPE_SECRET_KEY=

Default Values

Variables without annotations use their default value if provided:

PORT=3000
DEBUG=false

Non-Interactive Mode

In CI/CD environments, use --non-interactive:

  • Variables with @generate will be auto-generated
  • Variables with @prompt will be skipped (with a warning)
  • Variables with default values will use those defaults
  • Optional variables without values will be skipped