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.
1.8 KiB
1.8 KiB
+++
title = "nbd update diff output"
priority = 5
status = "done"
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
oldandnew. - 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. idis 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).
- If
Tests
Unit tests in src/tests.rs:
format_diffshows changed fields only.format_diffwith identical tickets outputs(no changes).- Changed dependencies are shown as comma-separated lists on each line.
Integration test:
nbd update <id> --status in_progress(no--json) prints- status:and+ status:lines.nbd update <id> --jsonstill prints full JSON (no diff).
Files touched
src/display.rs—format_diff,print_diffsrc/main.rs—cmd_updateusesprint_diffsrc/tests.rs— unit tests forformat_difftests/integration.rs— integration tests