You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.5 KiB
Markdown
37 lines
1.5 KiB
Markdown
---
|
|
# nbd-95l6
|
|
title: nbd init command
|
|
status: completed
|
|
type: feature
|
|
priority: high
|
|
created_at: 2026-03-10T23:30:30Z
|
|
updated_at: 2026-03-10T23:30:30Z
|
|
---
|
|
|
|
Add an explicit `nbd init` subcommand that creates `.nbd/tickets/` in the current working directory, analogous to `git init`.
|
|
|
|
## Motivation
|
|
|
|
Currently users must run `mkdir -p .nbd/tickets` manually before first use. This is a friction point — especially for first-time users and agent workflows bootstrapping a new project.
|
|
|
|
## Approach
|
|
|
|
1. Add `Init` variant to the `Commands` enum in `main.rs`.
|
|
2. Implement `cmd_init(json: bool) -> store::Result<()>`:
|
|
- Get cwd via `std::env::current_dir()`.
|
|
- Call `store::ensure_tickets_dir(&cwd)` (already exists, idempotent).
|
|
- Print confirmation: `initialised .nbd/tickets/ in <path>` (or JSON: `{"root": "<path>"}`).
|
|
3. No changes to `store.rs` needed — `ensure_tickets_dir` already uses `create_dir_all` (idempotent).
|
|
4. The command should NOT require `.nbd/` to already exist (i.e. do NOT call `find_nbd_root` here — use cwd directly).
|
|
|
|
## Tests
|
|
|
|
- Integration test: run `nbd init` in a fresh tempdir, verify `.nbd/tickets/` is created.
|
|
- Integration test: run `nbd init` twice in the same dir — succeeds both times (idempotent).
|
|
- Integration test: `nbd init --json` outputs valid JSON with a `root` field.
|
|
|
|
## Files touched
|
|
- `src/main.rs` — new `Init` variant and `cmd_init` handler
|
|
- `tests/integration.rs` — new integration tests
|
|
- `README.md` — update Initialise section
|