|
| 1 | +# config-utils |
| 2 | + |
| 3 | +A CLI tool for capturing environment variables and Django settings in YAML format. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **capture-env**: Capture all environment variables and export them to YAML |
| 8 | +- **capture-django-settings**: Capture Django project settings and export them to YAML |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +### Using uv tool install (Recommended) |
| 13 | + |
| 14 | +Install the tool globally using `uv`: |
| 15 | + |
| 16 | +```bash |
| 17 | +uv tool install . |
| 18 | +``` |
| 19 | + |
| 20 | +Or install from a remote location: |
| 21 | + |
| 22 | +```bash |
| 23 | +uv tool install config-utils |
| 24 | +``` |
| 25 | + |
| 26 | +This will install the `config-utils` executable in your PATH. |
| 27 | + |
| 28 | +### Using uvx |
| 29 | + |
| 30 | +Run the tool directly without installation: |
| 31 | + |
| 32 | +```bash |
| 33 | +uvx --from . config-utils capture-env |
| 34 | +``` |
| 35 | + |
| 36 | +### Using pip |
| 37 | + |
| 38 | +Install from the local directory: |
| 39 | + |
| 40 | +```bash |
| 41 | +pip install . |
| 42 | +``` |
| 43 | + |
| 44 | +Or install in editable mode for development: |
| 45 | + |
| 46 | +```bash |
| 47 | +pip install -e . |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | +## Usage |
| 52 | + |
| 53 | +### Capture Environment Variables |
| 54 | + |
| 55 | +Capture all environment variables to a YAML file: |
| 56 | + |
| 57 | +```bash |
| 58 | +config-utils capture-env |
| 59 | +``` |
| 60 | + |
| 61 | +This will create `env_config.yaml` with all your environment variables. |
| 62 | + |
| 63 | +#### Options |
| 64 | + |
| 65 | +- `-o, --output PATH`: Specify output file path (default: `env_config.yaml`) |
| 66 | +- `-f, --format`: Output format, yaml or yml (default: `yaml`) |
| 67 | + |
| 68 | +#### Examples |
| 69 | + |
| 70 | +```bash |
| 71 | +# Capture to custom file |
| 72 | +config-utils capture-env -o my_env.yaml |
| 73 | + |
| 74 | +# Capture with yml extension |
| 75 | +config-utils capture-env -o config.yml -f yml |
| 76 | +``` |
| 77 | + |
| 78 | +### Capture Django Settings |
| 79 | + |
| 80 | +Capture Django project settings to a YAML file using `python manage.py shell`: |
| 81 | + |
| 82 | +```bash |
| 83 | +# Run from your Django project directory |
| 84 | +cd /path/to/your/django/project |
| 85 | +config-utils capture-django-settings |
| 86 | +``` |
| 87 | + |
| 88 | +This will create `django_settings.yaml` with all Django settings. |
| 89 | + |
| 90 | +#### Options |
| 91 | + |
| 92 | +- `-o, --output PATH`: Specify output file path (default: `django_settings.yaml`) |
| 93 | +- `-f, --format`: Output format, yaml or yml (default: `yaml`) |
| 94 | +- `-m, --manage-py PATH`: Path to manage.py (default: `manage.py`) |
| 95 | +- `-s, --settings`: Django settings module (e.g., `myproject.settings`) |
| 96 | + |
| 97 | +#### Examples |
| 98 | + |
| 99 | +```bash |
| 100 | +# From Django project root directory |
| 101 | +config-utils capture-django-settings |
| 102 | + |
| 103 | +# Specifying settings module via command line |
| 104 | +config-utils capture-django-settings -s myproject.settings |
| 105 | + |
| 106 | +# Custom output file |
| 107 | +config-utils capture-django-settings -o my_django_config.yaml |
| 108 | + |
| 109 | +# Specify manage.py path if not in current directory |
| 110 | +config-utils capture-django-settings -m /path/to/manage.py |
| 111 | + |
| 112 | +# Using DJANGO_SETTINGS_MODULE environment variable |
| 113 | +export DJANGO_SETTINGS_MODULE=myproject.settings |
| 114 | +config-utils capture-django-settings |
| 115 | +``` |
| 116 | + |
| 117 | +**Note**: This command must be run from your Django project directory or you must specify the path to `manage.py` using the `--manage-py` option. |
| 118 | + |
| 119 | +### Using with uvx |
| 120 | + |
| 121 | +You can run the tool directly without installation: |
| 122 | + |
| 123 | +```bash |
| 124 | +# Capture environment variables |
| 125 | +uvx --from . config-utils capture-env |
| 126 | + |
| 127 | +# With options |
| 128 | +uvx --from . config-utils capture-env -o custom.yaml |
| 129 | + |
| 130 | +# Django settings (from Django project directory) |
| 131 | +cd /path/to/django/project |
| 132 | +uvx --from /path/to/config-utils config-utils capture-django-settings |
| 133 | + |
| 134 | +# Or specify manage.py path |
| 135 | +uvx --from /path/to/config-utils config-utils capture-django-settings -m /path/to/manage.py |
| 136 | +``` |
| 137 | + |
| 138 | +## Requirements |
| 139 | + |
| 140 | +- Python >= 3.8 |
| 141 | +- click >= 8.0.0 |
| 142 | +- pyyaml >= 6.0 |
| 143 | + |
| 144 | +**For Django settings capture**: The command uses `python manage.py shell`, so Django must be installed in your Django project's environment. The config-utils tool itself does not need Django as a dependency. |
| 145 | + |
| 146 | +## Development |
| 147 | + |
| 148 | +### Setup |
| 149 | + |
| 150 | +```bash |
| 151 | +# Clone or navigate to the project directory |
| 152 | +cd config-utils |
| 153 | + |
| 154 | +# Install in editable mode with development dependencies |
| 155 | +pip install -e . |
| 156 | +``` |
| 157 | + |
| 158 | +### Project Structure |
| 159 | + |
| 160 | +``` |
| 161 | +config-utils/ |
| 162 | +├── cli.py |
| 163 | +├── config_utils/ |
| 164 | +├── pyproject.toml |
| 165 | +└── README.md |
| 166 | +``` |
| 167 | + |
| 168 | +## License |
| 169 | + |
| 170 | +MIT License |
| 171 | + |
| 172 | +## Contributing |
| 173 | + |
| 174 | +Contributions are welcome! Please feel free to submit a Pull Request. |
0 commit comments