unify single user and multi user behaviour

This commit is contained in:
Davide Scaini
2026-04-09 08:58:35 +02:00
parent 2007f53580
commit 98c42dc443
25 changed files with 678 additions and 232 deletions
+45 -3
View File
@@ -4,6 +4,39 @@ All commands are run via `uv run bincio <command>` from the project root.
---
## bincio dev
Start the full local development environment. One command replaces the two-terminal setup.
```bash
uv sync --extra serve
uv run bincio dev [OPTIONS]
```
| Option | Default | Description |
|---|---|---|
| `--data-dir DIR` | auto-detected | BAS data directory (must contain `instance.db`) |
| `--site-dir DIR` | `./site` | Astro project directory |
| `--port PORT` | `4321` | Astro dev server port |
| `--api-port PORT` | `4041` | bincio serve API port |
`bincio dev` runs the following steps automatically:
1. Merges sidecar edits for all users (`merge_all()`)
2. Rewrites the root `index.json` shard manifest
3. Symlinks `site/public/data` → data directory
4. Starts `bincio serve` on `--api-port` in a background thread (**only if `instance.db` exists**)
5. Starts `astro dev` on `--port` in the foreground
No `.env` file needed — `BINCIO_DATA_DIR` and `PUBLIC_EDIT_URL` are set automatically.
Works in both modes:
- **Single-user** (no `instance.db`): no login, no API server, just `astro dev`
- **Multi-user** (`instance.db` present): starts `bincio serve` alongside `astro dev`
Ctrl+C stops everything.
---
## bincio extract
Extract GPX/FIT/TCX files into a BAS data store.
@@ -16,12 +49,21 @@ uv run bincio extract [OPTIONS]
|---|---|---|
| `--config PATH` | `extract_config.yaml` | Path to config file |
| `--input DIR` | from config | Input directory (scanned recursively) |
| `--output DIR` | from config | Output BAS data store directory |
| `--output DIR` | from config | Instance root directory |
| `--file PATH` | — | Extract a single file, print JSON to stdout |
| `--since DATE` | — | Only process files newer than this date (YYYY-MM-DD) |
| `--dev N` | — | Dev mode: sample N files evenly, output to `/tmp/bincio_dev/` |
Extraction is incremental by default — unchanged files (same hash) are skipped. To force a full re-extract: `rm -rf <output_dir>`.
`--output` (and `output.dir` in config) is the **instance root**, not the user directory. The handle from `owner.handle` in `extract_config.yaml` is always appended automatically:
```
bincio extract --output ~/bincio_data
# → writes to ~/bincio_data/{handle}/
```
This applies to both single-user and multi-user setups — the data layout is always the same.
Extraction is incremental by default — unchanged files (same hash) are skipped. To force a full re-extract, delete the user directory: `rm -rf ~/bincio_data/{handle}`.
Supported formats: GPX, FIT, TCX — all with optional `.gz` compression.
@@ -46,7 +88,7 @@ uv run bincio render [OPTIONS]
`bincio render` always:
1. Runs `merge_all()` — applies sidecar edits, produces `_merged/`
2. (Multi-user) Rewrites the root `index.json` shard manifest
2. Rewrites the root `index.json` shard manifest
3. Symlinks `site/public/data` → data directory
4. Runs `astro build` (or `astro dev` with `--serve`)