+++ title = "nbd update diff output" priority = 5 status = "todo" ticket_type = "feature" dependencies = [] +++ Show a git-diff-style +/- summary of what changed when `nbd update` is run without `--json`. ## Motivation Currently `nbd update` prints the full ticket after the change, making it hard to see at a glance what actually changed. A diff view — showing only changed fields — is more informative. ## Approach ### display.rs Add `format_diff(old: &Ticket, new: &Ticket) -> String`: - Compare each field between `old` and `new`. - For each field that changed, emit two lines: ``` - status: todo + status: in_progress ``` - If no fields changed, emit `(no changes)`. - Fields compared: `title`, `body`, `priority`, `status`, `ticket_type`, `dependencies`. - `id` is never shown (it cannot change). - Label width matches `format_ticket` (LABEL_WIDTH). Add `print_diff(old: &Ticket, new: &Ticket)` that calls `println!("{}" format_diff(...))`. ### main.rs In `cmd_update`: - Before applying changes: `let old = ticket.clone();` - After `write_ticket`: - If `json`: current behaviour (print new ticket as JSON). - Else: `display::print_diff(&old, &ticket)`. ## Tests Unit tests in `src/tests.rs`: - `format_diff` shows changed fields only. - `format_diff` with identical tickets outputs `(no changes)`. - Changed dependencies are shown as comma-separated lists on each line. Integration test: - `nbd update --status in_progress` (no `--json`) prints `- status:` and `+ status:` lines. - `nbd update --json` still prints full JSON (no diff). ## Files touched - `src/display.rs` — `format_diff`, `print_diff` - `src/main.rs` — `cmd_update` uses `print_diff` - `src/tests.rs` — unit tests for `format_diff` - `tests/integration.rs` — integration tests