passenv


Namepassenv JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryLoad environment variables from pass entries
upload_time2025-07-27 22:14:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords cli devops environment pass password
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PassEnv

Load environment variables from [pass](https://www.passwordstore.org/) entries seamlessly in your shell.

## Features

- **Secure**: Leverages the existing `pass` password manager
- **Simple**: Load/unload environment variables with a single command
- **Stateful**: Tracks what's loaded and prevents conflicts
- **Auto-completion**: Tab completion for pass entries
- **Shell Integration**: Works with bash, zsh, fish, and more

## Installation

### Prerequisites

- [pass](https://www.passwordstore.org/) must be installed and initialized
- Python 3.10 or higher

### Install from PyPI

```bash
pip install passenv
```

### Set up shell integration

After installation, run the setup command:

```bash
passenv install
```

This will add the necessary shell function and completion to your `~/.bashrc`, `~/.zshrc`, or specific shell rc file.

## Usage

### Basic Commands

```bash
# Load environment variables from a pass entry at database/envs
passenv load database/envs

# Check what's currently loaded
passenv status

# List available pass entries
passenv list

# Unload current environment
passenv unload

# Export as .env format (default)
passenv export database/envs
```

### Pass Entry Format

Store your environment variables in pass entries using the `KEY=VALUE` format:

```bash
# Create a pass entry
pass edit database/envs
```

Example entry content:
```
DATABASE_URL=postgres://user:pass@localhost/mydb
API_KEY=secret123
DEBUG=false
# This is a comment
LOG_LEVEL=info
```

### Advanced Usage

#### Environment Isolation

PassEnv automatically handles environment isolation:

- Loading a new set of environment variables automatically unloads the previous ones
- Tracks which variables were loaded to prevent conflicts
- Provides clear status information

## Examples

### Development Workflow

```bash
# Load development environment
passenv load myapp/development

# Run your application
python manage.py runserver

# Switch to staging environment
passenv load myapp/staging

# Deploy to staging
./deploy.sh

# Clean up
passenv unload
```

### Basic Export Usage

```bash
# Export as .env format (default)
passenv export database/envs

# Export to different formats
passenv export database/envs --format yaml
passenv export database/envs --format json
passenv export database/envs --format csv
passenv export database/envs --format docker

# Save to file
passenv export database/envs --output .env
passenv export database/envs --format yaml --output config.yaml
```

### Export Formats

#### .env format (default)
```bash
passenv export myapp/production
```
Output:
```
DATABASE_URL=postgres://user:pass@localhost/mydb
API_KEY=secret123
DEBUG=false
LOG_LEVEL=info
```

#### YAML format
```bash
passenv export myapp/production --format yaml
```
Output:
```yaml
DATABASE_URL: postgres://user:pass@localhost/mydb
API_KEY: secret123
DEBUG: "false"
LOG_LEVEL: info
```

#### JSON format
```bash
passenv export myapp/production --format json
```
Output:
```json
{
  "DATABASE_URL": "postgres://user:pass@localhost/mydb",
  "API_KEY": "secret123", 
  "DEBUG": "false",
  "LOG_LEVEL": "info"
}
```

#### CSV format
```bash
passenv export myapp/production --format csv
```
Output:
```csv
KEY,VALUE
DATABASE_URL,postgres://user:pass@localhost/mydb
API_KEY,secret123
DEBUG,false
LOG_LEVEL,info
```

#### Docker format
```bash
passenv export myapp/production --format docker
```
Output:
```
-e DATABASE_URL="postgres://user:pass@localhost/mydb" -e API_KEY="secret123" -e DEBUG="false" -e LOG_LEVEL="info"
```

### Docker Integration Examples

```bash
# Export and use directly with docker run
docker run $(passenv export myapp/production --format docker) my-app:latest

# Save to file and use with docker-compose
passenv export myapp/production --output .env
docker-compose up

# Use with Kubernetes ConfigMap
passenv export myapp/production --format yaml --output configmap.yaml
kubectl create configmap app-config --from-file=configmap.yaml
```

### Pass Entry Organization Suggestion

Organize your pass entries logically:

```
myapp/
├── development
├── staging
└── production

database/
├── local
├── staging
└── production
```

### Environment Variable Format

- **Comments**: Lines starting with `#` are ignored
- **Empty lines**: Skipped automatically
- **Format**: `KEY=VALUE` (spaces around `=` are stripped)
- **Quotes**: Optional quotes around values are removed
- **Variable names**: Must be valid shell variable names (`[A-Za-z_][A-Za-z0-9_]*`)

## Troubleshooting

### Common Issues

**Pass not found**
```
Error: 'pass' command not found. Please install pass.
```
Install pass using your package manager:
```bash
# Ubuntu/Debian
sudo apt install pass

# macOS
brew install pass

# Arch Linux
sudo pacman -S pass
```

**Pass not initialized**
```
Error: Pass store not initialized.
```
Initialize your pass store:
```bash
pass init your-gpg-key-id
```

**Entry not found**
```
Error: Pass entry 'myapp/staging' not found.
```
Create the entry:
```bash
pass edit myapp/staging
```

**Invalid variable format**
```
Error: Invalid line 'malformed-line' in pass entry.
```
Check your pass entry format. Each line should be `KEY=VALUE` or a comment.

### Getting Help

```bash
# Show help
passenv --help

# Show command-specific help
passenv load --help
```

## Development

### Local Development

```bash
# Clone the repository
git clone https://github.com/yourusername/passenv.git
cd passenv

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black src/ tests/
isort src/ tests/

# Type checking
mypy src/
```

### Testing

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=passenv

# Run specific test file
pytest tests/test_parser.py
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Run the test suite
6. Submit a pull request

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Related Projects

- [pass](https://www.passwordstore.org/) - The password manager this tool integrates with

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "passenv",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "cli, devops, environment, pass, password",
    "author": null,
    "author_email": "Victor Gambarini <victor.gambarini@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fa/99/72b0f587438095a4aecf8823f0e4abcf348ccf57d62e78cacae2c8e9e699/passenv-0.3.0.tar.gz",
    "platform": null,
    "description": "# PassEnv\n\nLoad environment variables from [pass](https://www.passwordstore.org/) entries seamlessly in your shell.\n\n## Features\n\n- **Secure**: Leverages the existing `pass` password manager\n- **Simple**: Load/unload environment variables with a single command\n- **Stateful**: Tracks what's loaded and prevents conflicts\n- **Auto-completion**: Tab completion for pass entries\n- **Shell Integration**: Works with bash, zsh, fish, and more\n\n## Installation\n\n### Prerequisites\n\n- [pass](https://www.passwordstore.org/) must be installed and initialized\n- Python 3.10 or higher\n\n### Install from PyPI\n\n```bash\npip install passenv\n```\n\n### Set up shell integration\n\nAfter installation, run the setup command:\n\n```bash\npassenv install\n```\n\nThis will add the necessary shell function and completion to your `~/.bashrc`, `~/.zshrc`, or specific shell rc file.\n\n## Usage\n\n### Basic Commands\n\n```bash\n# Load environment variables from a pass entry at database/envs\npassenv load database/envs\n\n# Check what's currently loaded\npassenv status\n\n# List available pass entries\npassenv list\n\n# Unload current environment\npassenv unload\n\n# Export as .env format (default)\npassenv export database/envs\n```\n\n### Pass Entry Format\n\nStore your environment variables in pass entries using the `KEY=VALUE` format:\n\n```bash\n# Create a pass entry\npass edit database/envs\n```\n\nExample entry content:\n```\nDATABASE_URL=postgres://user:pass@localhost/mydb\nAPI_KEY=secret123\nDEBUG=false\n# This is a comment\nLOG_LEVEL=info\n```\n\n### Advanced Usage\n\n#### Environment Isolation\n\nPassEnv automatically handles environment isolation:\n\n- Loading a new set of environment variables automatically unloads the previous ones\n- Tracks which variables were loaded to prevent conflicts\n- Provides clear status information\n\n## Examples\n\n### Development Workflow\n\n```bash\n# Load development environment\npassenv load myapp/development\n\n# Run your application\npython manage.py runserver\n\n# Switch to staging environment\npassenv load myapp/staging\n\n# Deploy to staging\n./deploy.sh\n\n# Clean up\npassenv unload\n```\n\n### Basic Export Usage\n\n```bash\n# Export as .env format (default)\npassenv export database/envs\n\n# Export to different formats\npassenv export database/envs --format yaml\npassenv export database/envs --format json\npassenv export database/envs --format csv\npassenv export database/envs --format docker\n\n# Save to file\npassenv export database/envs --output .env\npassenv export database/envs --format yaml --output config.yaml\n```\n\n### Export Formats\n\n#### .env format (default)\n```bash\npassenv export myapp/production\n```\nOutput:\n```\nDATABASE_URL=postgres://user:pass@localhost/mydb\nAPI_KEY=secret123\nDEBUG=false\nLOG_LEVEL=info\n```\n\n#### YAML format\n```bash\npassenv export myapp/production --format yaml\n```\nOutput:\n```yaml\nDATABASE_URL: postgres://user:pass@localhost/mydb\nAPI_KEY: secret123\nDEBUG: \"false\"\nLOG_LEVEL: info\n```\n\n#### JSON format\n```bash\npassenv export myapp/production --format json\n```\nOutput:\n```json\n{\n  \"DATABASE_URL\": \"postgres://user:pass@localhost/mydb\",\n  \"API_KEY\": \"secret123\", \n  \"DEBUG\": \"false\",\n  \"LOG_LEVEL\": \"info\"\n}\n```\n\n#### CSV format\n```bash\npassenv export myapp/production --format csv\n```\nOutput:\n```csv\nKEY,VALUE\nDATABASE_URL,postgres://user:pass@localhost/mydb\nAPI_KEY,secret123\nDEBUG,false\nLOG_LEVEL,info\n```\n\n#### Docker format\n```bash\npassenv export myapp/production --format docker\n```\nOutput:\n```\n-e DATABASE_URL=\"postgres://user:pass@localhost/mydb\" -e API_KEY=\"secret123\" -e DEBUG=\"false\" -e LOG_LEVEL=\"info\"\n```\n\n### Docker Integration Examples\n\n```bash\n# Export and use directly with docker run\ndocker run $(passenv export myapp/production --format docker) my-app:latest\n\n# Save to file and use with docker-compose\npassenv export myapp/production --output .env\ndocker-compose up\n\n# Use with Kubernetes ConfigMap\npassenv export myapp/production --format yaml --output configmap.yaml\nkubectl create configmap app-config --from-file=configmap.yaml\n```\n\n### Pass Entry Organization Suggestion\n\nOrganize your pass entries logically:\n\n```\nmyapp/\n\u251c\u2500\u2500 development\n\u251c\u2500\u2500 staging\n\u2514\u2500\u2500 production\n\ndatabase/\n\u251c\u2500\u2500 local\n\u251c\u2500\u2500 staging\n\u2514\u2500\u2500 production\n```\n\n### Environment Variable Format\n\n- **Comments**: Lines starting with `#` are ignored\n- **Empty lines**: Skipped automatically\n- **Format**: `KEY=VALUE` (spaces around `=` are stripped)\n- **Quotes**: Optional quotes around values are removed\n- **Variable names**: Must be valid shell variable names (`[A-Za-z_][A-Za-z0-9_]*`)\n\n## Troubleshooting\n\n### Common Issues\n\n**Pass not found**\n```\nError: 'pass' command not found. Please install pass.\n```\nInstall pass using your package manager:\n```bash\n# Ubuntu/Debian\nsudo apt install pass\n\n# macOS\nbrew install pass\n\n# Arch Linux\nsudo pacman -S pass\n```\n\n**Pass not initialized**\n```\nError: Pass store not initialized.\n```\nInitialize your pass store:\n```bash\npass init your-gpg-key-id\n```\n\n**Entry not found**\n```\nError: Pass entry 'myapp/staging' not found.\n```\nCreate the entry:\n```bash\npass edit myapp/staging\n```\n\n**Invalid variable format**\n```\nError: Invalid line 'malformed-line' in pass entry.\n```\nCheck your pass entry format. Each line should be `KEY=VALUE` or a comment.\n\n### Getting Help\n\n```bash\n# Show help\npassenv --help\n\n# Show command-specific help\npassenv load --help\n```\n\n## Development\n\n### Local Development\n\n```bash\n# Clone the repository\ngit clone https://github.com/yourusername/passenv.git\ncd passenv\n\n# Install in development mode\npip install -e \".[dev]\"\n\n# Run tests\npytest\n\n# Format code\nblack src/ tests/\nisort src/ tests/\n\n# Type checking\nmypy src/\n```\n\n### Testing\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=passenv\n\n# Run specific test file\npytest tests/test_parser.py\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Run the test suite\n6. Submit a pull request\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Related Projects\n\n- [pass](https://www.passwordstore.org/) - The password manager this tool integrates with\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Load environment variables from pass entries",
    "version": "0.3.0",
    "project_urls": {
        "Documentation": "https://github.com/VictorGambarini/passenv#readme",
        "Homepage": "https://github.com/VictorGambarini/passenv",
        "Issues": "https://github.com/VictorGambarini/passenv/issues",
        "Repository": "https://github.com/VictorGambarini/passenv"
    },
    "split_keywords": [
        "cli",
        " devops",
        " environment",
        " pass",
        " password"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "99d5c818f2fa78afb76c68be325b80fa578b645f990ae965f649abb8413e994d",
                "md5": "d8cf95326a5c823a145bd4359eda46eb",
                "sha256": "d28952883fa78c7609a6723c5cc84d2b9ed295af983e3ba716da0dfbbeb37eb8"
            },
            "downloads": -1,
            "filename": "passenv-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d8cf95326a5c823a145bd4359eda46eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 11548,
            "upload_time": "2025-07-27T22:14:35",
            "upload_time_iso_8601": "2025-07-27T22:14:35.765571Z",
            "url": "https://files.pythonhosted.org/packages/99/d5/c818f2fa78afb76c68be325b80fa578b645f990ae965f649abb8413e994d/passenv-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fa9972b0f587438095a4aecf8823f0e4abcf348ccf57d62e78cacae2c8e9e699",
                "md5": "a1ddc6e7531aca96185ccd6f589daef2",
                "sha256": "5b9450c42cd2164a276f43f52f80941004b7ec7ad29251c13ff506b44663a2d1"
            },
            "downloads": -1,
            "filename": "passenv-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a1ddc6e7531aca96185ccd6f589daef2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 11280,
            "upload_time": "2025-07-27T22:14:36",
            "upload_time_iso_8601": "2025-07-27T22:14:36.683669Z",
            "url": "https://files.pythonhosted.org/packages/fa/99/72b0f587438095a4aecf8823f0e4abcf348ccf57d62e78cacae2c8e9e699/passenv-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-27 22:14:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "VictorGambarini",
    "github_project": "passenv#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "passenv"
}
        
Elapsed time: 4.28896s