implemented proper error handling, added README
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
# dev_tools
|
||||
|
||||
CLI tool to start and stop a local RCC test environment. It manages a Docker Compose service and toggles environment variable files between local and CI database configurations.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Rust toolchain (stable)
|
||||
- Docker with Compose plugin
|
||||
|
||||
## Configuration
|
||||
|
||||
The tool reads from a dotenv-style file at `~/.config/rcc/dev`. The following variables are required:
|
||||
|
||||
| Variable | Description |
|
||||
|---|---|
|
||||
| `DOCKER_SERVICE` | Name of the Docker container to check if it is running |
|
||||
| `DOCKER_DIR` | Path to the Docker Compose directory, relative to `$HOME` |
|
||||
| `<PROJECT>_DIR` | Absolute path to the project directory (one per project, e.g. `FOO_DIR`) |
|
||||
|
||||
Example `~/.config/rcc/dev`:
|
||||
```
|
||||
DOCKER_SERVICE=my-container
|
||||
DOCKER_DIR=repos/docker/local
|
||||
FOO_DIR=/home/user/repos/foo
|
||||
```
|
||||
|
||||
## Build & Install
|
||||
|
||||
```bash
|
||||
cargo build --release
|
||||
# or install directly into ~/.cargo/bin
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
dev_tools <project> <up|down> [--legacy]
|
||||
```
|
||||
|
||||
| Argument | Description |
|
||||
|---|---|
|
||||
| `project` | Project key (matches `<PROJECT>_DIR` in the config, case-insensitive) |
|
||||
| `up` / `down` | Start or stop the environment |
|
||||
| `-l`, `--legacy` | Enable legacy mode: also toggles `conf/global/connections.env` and runs `git update-index` |
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# Start the environment for project "foo"
|
||||
dev_tools foo up
|
||||
|
||||
# Stop it
|
||||
dev_tools foo down
|
||||
|
||||
# Start with legacy env handling
|
||||
dev_tools foo up --legacy
|
||||
```
|
||||
|
||||
## What it does
|
||||
|
||||
1. Starts or stops the Docker Compose service defined by `DOCKER_SERVICE` / `DOCKER_DIR`.
|
||||
2. Toggles database connection entries in `<PROJECT_DIR>/conf/local/.env` between `staging` and CI values.
|
||||
3. With `--legacy`: additionally modifies `conf/global/connections.env` and marks it with `git update-index --assume-unchanged` to avoid accidental commits.
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
cargo test
|
||||
```
|
||||
Reference in New Issue
Block a user