Files
beads/cmd/bd
Steve Yegge c835b81d72 Fix: init command now respects --db flag and BEADS_DB env var
Fixes #118 - Users can now initialize databases outside project directory

Changes:
- Check BEADS_DB env var in init command (PersistentPreRun skipped for init)
- Use global dbPath from --db flag or BEADS_DB, else default to .beads/{prefix}.db
- Use canonical path comparison (filepath.Abs + Clean) instead of strings.Contains
- Only create .beads/ directory when database is actually local
- Ensure parent directory exists for custom database paths
- Add comprehensive tests for --db flag, BEADS_DB env var, and edge cases
- Fix test isolation by resetting global dbPath in test setup

Tests:
- Custom path with --db flag
- Custom path with BEADS_DB env var
- Custom path containing ".beads" substring (prevents false positive)
- Flag precedence over env var
- All existing tests still pass

Amp-Thread-ID: https://ampcode.com/threads/T-04e2c94f-894a-4b49-8132-980450b2300d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-23 10:58:35 -07:00
..
2025-10-20 21:08:49 -07:00
2025-10-20 21:08:49 -07:00
2025-10-20 21:08:49 -07:00
2025-10-21 20:34:37 -07:00
2025-10-20 21:08:49 -07:00
2025-10-20 21:08:49 -07:00
2025-10-20 21:08:49 -07:00
2025-10-20 21:08:49 -07:00
2025-10-22 23:15:18 -07:00