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.
vibed/nbd/.beans/nbd-6j0q--print-tickets-in-...

101 lines
2.8 KiB
Markdown

---
# nbd-6j0q
title: Print tickets in markdown format instead of key-value table
status: completed
type: feature
priority: normal
created_at: 2026-03-10T23:30:30Z
updated_at: 2026-03-10T23:30:30Z
---
## Goal
When a ticket is printed to stdout (e.g. by `nbd read`, `nbd create`, `nbd archive`, `nbd next`, `nbd update` without `--json`), it should be rendered as markdown with TOML frontmatter — the same format used by `--ftype md` files on disk — rather than the current key-value table.
`--json` output is unaffected.
## Current output (`nbd read <id>`)
```
ID: a3f9c2
Title: Fix login bug
Body: Users cannot log in with email +
Priority: 8
Status: in_progress
Type: bug
Dependencies: b7d41e, c9e823
```
## Target output
```
+++
title = "Fix login bug"
priority = 8
status = "in_progress"
ticket_type = "bug"
dependencies = ["b7d41e", "c9e823"]
+++
Users cannot log in with email +
```
The `id` field is not in the frontmatter on disk (filename is the source of truth), but for display purposes it should appear as a comment or additional line. Recommended approach: add `id = "a3f9c2"` as the **first key** in the frontmatter so it's immediately visible:
```
+++
id = "a3f9c2"
title = "Fix login bug"
priority = 8
status = "in_progress"
ticket_type = "bug"
dependencies = ["b7d41e", "c9e823"]
+++
Users cannot log in with email +
```
## Files to change
### `src/display.rs`
Replace `format_ticket` with a markdown-rendering implementation. The simplest approach reuses `serialize_markdown` from `src/store.rs`, adding `id` to the frontmatter output.
Option A (preferred): expose `serialize_markdown` from `store.rs` as `pub(crate)` and call it from `display.rs`, prepending the `id` line to the TOML frontmatter block.
Option B: duplicate the logic in `display.rs` as a display-specific formatter that includes `id`.
The `print_ticket` function should call the new formatter.
### `src/tests.rs`
Update any unit tests for `format_ticket` that check the old key-value table format. They should now expect TOML frontmatter.
### `tests/integration.rs`
Update any integration tests that check the plain-text output of `nbd read`, `nbd create`, etc.
## Commands affected
Any command that calls `display::print_ticket`:
- `nbd create` (non-JSON path)
- `nbd read` (non-JSON path)
- `nbd archive` (non-JSON path)
- `nbd next` (non-JSON path, single ticket)
- `nbd update` currently calls `print_diff`, so it is **not** affected
## Validation
```sh
cargo fmt && cargo check && cargo clippy && cargo test
cargo run -- create --title "Test ticket" --body "Some body text" --priority 7 --type bug
# Output should be:
# +++
# id = "<id>"
# title = "Test ticket"
# priority = 7
# status = "todo"
# ticket_type = "bug"
# dependencies = []
# +++
# Some body text
```