Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1137f29cf | ||
|
|
77bf2d9e2a | ||
|
|
78831f1a39 |
@@ -176,12 +176,29 @@ worklane comment "My Ticket" "Needs changes to the UI"
|
||||
worklane comment a1b2c3d4 "LGTM, approved"
|
||||
```
|
||||
|
||||
## Workflow
|
||||
## Working a ticket
|
||||
|
||||
1. Use `worklane add` to create tickets with all relevant details
|
||||
2. Use `worklane ls [status]` to view tickets by status
|
||||
3. Use `worklane show <id>` to view full ticket details
|
||||
4. Use `worklane mv <id> --status <target>` to move tickets through the workflow
|
||||
5. Use `worklane set <ticket>` to correct a field, or `worklane append <ticket>` to add to a section
|
||||
6. Use `worklane check <ticket> <n>` to tick a criterion as it is met
|
||||
7. Use `worklane comment <ticket> <body>` to add notes to tickets
|
||||
Move the ticket as you work it, not afterwards. The board should say what is happening
|
||||
now, not only what already landed.
|
||||
|
||||
1. `worklane show <id>` to read it
|
||||
2. **`worklane mv <id> --status committed` before writing any code.** This is what marks
|
||||
the ticket as being worked on, so it belongs at the start
|
||||
3. Do the work. `worklane check <id> <n>` as each criterion is met
|
||||
4. `worklane comment <id> <body>` with anything worth recording: a decision, a rejected
|
||||
acceptance criterion, something the ticket got wrong
|
||||
5. **`worklane mv <id> --status reviewing` once it is done and the tests pass**
|
||||
|
||||
Only one stage forward is allowed at a time, so a ticket left in `backlog` until the end
|
||||
cannot go straight to `reviewing`. It has to be walked through `committed` anyway, which
|
||||
makes moving it up front the same two commands in a more useful order.
|
||||
|
||||
## Commands
|
||||
|
||||
- `worklane add` creates tickets with all relevant details
|
||||
- `worklane ls [status]` views tickets by status
|
||||
- `worklane show <id>` views full ticket details
|
||||
- `worklane mv <id> --status <target>` moves tickets through the workflow
|
||||
- `worklane set <ticket>` corrects a field, `worklane append <ticket>` adds to a section
|
||||
- `worklane check <ticket> <n>` ticks a criterion as it is met
|
||||
- `worklane comment <ticket> <body>` adds notes to tickets
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
# AGENTS.md
|
||||
|
||||
## Project Structure
|
||||
- `src/main.rs` - All application logic
|
||||
- `src/main.rs` - dispatch, the SIGPIPE reset, and the TUI event loop
|
||||
- `src/command.rs` - CLI argument definitions using clap derive
|
||||
- `tests/` - Integration tests using `assert_cmd` and `assert_fs`
|
||||
- `src/handlers.rs` - one `cmd_*` per subcommand
|
||||
- `src/util.rs` - the ticket format, resolution, rendering and the palette
|
||||
- `src/tui.rs` - board state, the change digest, and the ratatui draw
|
||||
- `tests/` - Integration tests using `assert_cmd` and `assert_fs`, one file per command
|
||||
- Unit tests live beside the code in `#[cfg(test)] mod tests`, in `util.rs`, `handlers.rs` and `tui.rs`
|
||||
- Ticket files stored as `.md` in `.worklane/<status>/` directories
|
||||
|
||||
## Ticket File Format
|
||||
@@ -16,6 +20,15 @@
|
||||
## Status Workflow
|
||||
`backlog` → `committed` → `reviewing` → `done`
|
||||
|
||||
**Move the ticket as you work it, not afterwards.** `mv <id> --status committed` before
|
||||
writing any code, and `mv <id> --status reviewing` once it is done and the tests pass.
|
||||
The board is then true while the work is in progress, not only after it lands, which is
|
||||
the whole point of having a `committed` column.
|
||||
|
||||
Only one stage at a time is allowed, so a ticket left in `backlog` until the end cannot
|
||||
go straight to `reviewing` and has to be walked through `committed` anyway. Doing it up
|
||||
front is the same two commands in a more useful order.
|
||||
|
||||
## Testing
|
||||
- Run: `cargo test`
|
||||
- Tests use `assert_cmd` and `assert_fs` for CLI testing
|
||||
@@ -62,9 +75,25 @@
|
||||
- With the criterion omitted: prompt when stdin is a terminal, otherwise return the numbered list as an error. Never prompt unconditionally, the opencode wrapper has no tty and would block on a stdin that never closes. This is the same choice `resolve_ticket` makes for an ambiguous match, and for the same reason
|
||||
- `show` numbers the criteria as `1. [x] text`, so the index is visible where the ticket is read. The number replaces the list marker rather than joining it
|
||||
|
||||
### The Board View
|
||||
- `worklane` with no subcommand and `worklane tui` both open it, the way a bare `frig` does. `Cli::command` is therefore an `Option`
|
||||
- The worklane directory is looked for **before** the terminal, so running outside one gives the usual "No .worklane directory found" rather than a complaint about the tty. Both errors stay reachable and both are testable without a pty
|
||||
- A missing tty is refused with a message naming a subcommand. Raw mode on a pipe fails with a bare "No such device or address (os error 6)", which explains nothing
|
||||
- **The watch looks at files, not directories.** A directory's mtime only moves on create and rename, so a ticket edited in place would be missed. `digest()` hashes every ticket and comment file's path, length and mtime. Comment files are in it because a comment added elsewhere has to reach the detail view
|
||||
- The digest guards the *rescan*, not the draw. ratatui diffs its buffer, so drawing every iteration is free; reading the tree every iteration is not
|
||||
- `notify` is deliberately not a dependency. Polling a tree of tens of small files on the 250ms tick is enough, and the reason is recorded on f6af387
|
||||
- Cards come from `collect_ticket_items`, the same source `ls` uses, so there is no second parser. `TicketItem::path` exists for the detail view
|
||||
- **The detail view scrolls on `pgup` and `pgdn`, not on up and down.** Up and down stay on the selection with the modal open, so a whole column can be read without closing it, and the modal follows. That is worth more than the two keys, which is why the scroll went elsewhere rather than taking them
|
||||
- The scroll offset is clamped against the *wrapped* line count, from `Paragraph::line_count`, which is why `ratatui` carries the `unstable-rendered-line-info` feature. The paragraph wraps on words, so a clamp on the raw lines would stop short of the end or scroll past it into blank space. Counting the wrapping by hand would only agree with the widget until one of the two changed
|
||||
- The clamp runs on the keypress and again in the draw. The terminal can be resized between the two, and a tick can shorten the ticket under a reader who is already at the end
|
||||
- The offset resets when the selection moves and when the modal is closed, so a ticket opens at its top. It deliberately does *not* reset on a tick: an edit elsewhere in the tree must not throw the reader back to the top of what they are reading
|
||||
- **The footer names only keys that work.** It read `↑↓ scroll` when nothing scrolled at all, which sends the reader looking for their own mistake. A UI that misdescribes itself is worse than one that is merely incomplete
|
||||
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_comments_with` take the colour decision for that reason
|
||||
- Read only. Moving a card by keypress is a follow-up, deliberately kept out until the watch and render loop were solid
|
||||
|
||||
### Color and Output
|
||||
- Use `color_text()` helper for colored output — it respects `should_use_colors()` (terminal detection)
|
||||
- Color codes are defined in `get_color()`: red (31), cyan (36), orange (33), green (32), grey (38;5;8), magenta (1;35), brightred (38;5;9)
|
||||
- Use `color_text()` for coloured output — it respects `should_use_colors()` (terminal detection), and `paint()` is the same with the decision passed in
|
||||
- **The palette is the `Color` enum, not a string.** `Color::ansi()` gives the CLI its SGR sequence and `From<Color> for ratatui::style::Color` gives the TUI its equivalent, so a colour that exists for one renderer and not the other is a compile error. The stringly-typed version needed a test for exactly that, and a missing entry silently produced an empty prefix, which is how `magenta` came to be undefined
|
||||
- Reset color with `\x1b[0m` after colored text
|
||||
- Bold uses `\x1b[1;35m` (magenta bold)
|
||||
- Always test color output works correctly in both terminal and pipe modes
|
||||
|
||||
Generated
+484
-17
@@ -11,6 +11,12 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
@@ -56,7 +62,7 @@ version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -67,7 +73,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -135,6 +141,21 @@ version = "3.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||
|
||||
[[package]]
|
||||
name = "cassowary"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
|
||||
|
||||
[[package]]
|
||||
name = "castaway"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.62"
|
||||
@@ -196,7 +217,7 @@ dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -211,6 +232,20 @@ version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"cfg-if",
|
||||
"itoa",
|
||||
"rustversion",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
@@ -242,6 +277,65 @@ version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.28.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crossterm_winapi",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"rustix 0.38.44",
|
||||
"signal-hook",
|
||||
"signal-hook-mio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm_winapi"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
|
||||
dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "difflib"
|
||||
version = "0.4.0"
|
||||
@@ -254,6 +348,12 @@ version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "780955b8b195a21ab8e4ac6b60dd1dbdcec1dc6c51c0617964b08c81785e12c9"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
@@ -267,7 +367,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -355,6 +455,8 @@ version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
@@ -400,6 +502,12 @@ version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.4.25"
|
||||
@@ -428,12 +536,43 @@ dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instability"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bf84e73fa6f27f299dec58e13223cf70db80da872eb921d4f6138342a0eabc8"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"indoc",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
@@ -464,24 +603,60 @@ version = "0.2.186"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -503,6 +678,35 @@ version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.17"
|
||||
@@ -543,7 +747,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -570,6 +774,36 @@ version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm",
|
||||
"indoc",
|
||||
"instability",
|
||||
"itertools",
|
||||
"lru",
|
||||
"paste",
|
||||
"strum",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.14"
|
||||
@@ -587,6 +821,19 @@ version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.4"
|
||||
@@ -596,8 +843,8 @@ dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -606,6 +853,12 @@ version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
@@ -615,6 +868,12 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
@@ -647,7 +906,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -669,18 +928,83 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"signal-hook-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-mio"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"mio",
|
||||
"signal-hook",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
|
||||
dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.26.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
|
||||
dependencies = [
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.26.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.117"
|
||||
@@ -692,6 +1016,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.27.0"
|
||||
@@ -701,8 +1036,8 @@ dependencies = [
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
"rustix 1.1.4",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -717,6 +1052,35 @@ version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-truncate"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"unicode-segmentation",
|
||||
"unicode-width 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
@@ -759,6 +1123,12 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.3+wasi-0.2.9"
|
||||
@@ -809,7 +1179,7 @@ dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@@ -856,15 +1226,37 @@ dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
@@ -886,7 +1278,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -897,7 +1289,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -924,6 +1316,15 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
@@ -933,6 +1334,70 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.51.0"
|
||||
@@ -969,7 +1434,7 @@ dependencies = [
|
||||
"heck",
|
||||
"indexmap",
|
||||
"prettyplease",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wasm-metadata",
|
||||
"wit-bindgen-core",
|
||||
"wit-component",
|
||||
@@ -985,7 +1450,7 @@ dependencies = [
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wit-bindgen-core",
|
||||
"wit-bindgen-rust",
|
||||
]
|
||||
@@ -1029,14 +1494,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
"assert_fs",
|
||||
"chrono",
|
||||
"clap",
|
||||
"crossterm",
|
||||
"libc",
|
||||
"ratatui",
|
||||
"tempfile",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
+6
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
@@ -9,6 +9,11 @@ anyhow = "1"
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
libc = "0.2"
|
||||
# unstable-rendered-line-info for Paragraph::line_count, which is how the detail view
|
||||
# knows where its text ends. Counting the wrapping by hand would only agree with the
|
||||
# widget until one of us changed.
|
||||
ratatui = { version = "0.29", features = ["unstable-rendered-line-info"] }
|
||||
crossterm = "0.28"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "2"
|
||||
|
||||
@@ -5,6 +5,7 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
## Commands
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `worklane` or `worklane tui` | Opens the board: four status columns, redrawn when the tree changes. Read only. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket, `q` to quit |
|
||||
| `worklane init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
|
||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
|
||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
|
||||
|
||||
+5
-1
@@ -33,8 +33,9 @@ const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", env!("WORKLANE_GI
|
||||
#[command(version = VERSION)]
|
||||
#[command(propagate_version = true)]
|
||||
pub struct Cli {
|
||||
/// Absent opens the board view, the way a bare `frig` does.
|
||||
#[command(subcommand)]
|
||||
pub command: Command,
|
||||
pub command: Option<Command>,
|
||||
}
|
||||
|
||||
/// Reject an empty value at parse time, so it lands as a usage error rather than a
|
||||
@@ -140,6 +141,9 @@ pub enum Command {
|
||||
/// Add to a section of an existing ticket
|
||||
Append(AppendArgs),
|
||||
|
||||
/// Open the board view
|
||||
Tui,
|
||||
|
||||
/// Tick an acceptance criterion
|
||||
Check(CheckArgs),
|
||||
|
||||
|
||||
+15
-14
@@ -84,7 +84,7 @@ pub fn cmd_ls(
|
||||
if items.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let status_header = color_text(&format!("[{}]", status.to_uppercase()), "orange");
|
||||
let status_header = color_text(&format!("[{}]", status.to_uppercase()), Color::Orange);
|
||||
println!("\n{}", status_header);
|
||||
display_ticket_items(&items);
|
||||
}
|
||||
@@ -210,7 +210,8 @@ pub fn cmd_add(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
|
||||
/// Public for the TUI's detail view, which shows the same comments `show` does.
|
||||
pub fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
|
||||
if !comments_dir.exists() {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
@@ -301,7 +302,7 @@ pub fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> {
|
||||
// The only title in the output: content_trim_colored used to print it a second
|
||||
// time from the file content. Green per the colour guideline, and the rule is
|
||||
// measured in characters so a non-ASCII title is not over-drawn.
|
||||
println!("{}", color_text(&title, "green"));
|
||||
println!("{}", color_text(&title, Color::Green));
|
||||
println!("{}", "─".repeat(title.chars().count()));
|
||||
println!("\n{}", content_trim_colored(&content));
|
||||
|
||||
@@ -456,8 +457,8 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
|
||||
if !force && target_idx < current_idx {
|
||||
return Err(anyhow!(
|
||||
"Cannot move backward from {} to {}. Use --force (-f) to allow.",
|
||||
color_text(¤t_status, "orange"),
|
||||
color_text(target_status, "orange"),
|
||||
color_text(¤t_status, Color::Orange),
|
||||
color_text(target_status, Color::Orange),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -470,7 +471,7 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
|
||||
if current_status == target_status {
|
||||
println!(
|
||||
"Ticket is already in '{}' status.",
|
||||
color_text(&target_status, "orange")
|
||||
color_text(&target_status, Color::Orange)
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
@@ -496,9 +497,9 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
|
||||
|
||||
println!(
|
||||
"Moved ticket '{}' from {} to {}",
|
||||
color_text(&title, "green"),
|
||||
color_text(¤t_status, "orange"),
|
||||
color_text(target_status, "orange"),
|
||||
color_text(&title, Color::Green),
|
||||
color_text(¤t_status, Color::Orange),
|
||||
color_text(target_status, Color::Orange),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -640,7 +641,7 @@ fn save_ticket(
|
||||
|
||||
fn report(fields: &[&str], title: &str, verb: &str) {
|
||||
if fields.is_empty() {
|
||||
println!("No changes to '{}'", color_text(title, "green"));
|
||||
println!("No changes to '{}'", color_text(title, Color::Green));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -648,7 +649,7 @@ fn report(fields: &[&str], title: &str, verb: &str) {
|
||||
"{} {} on '{}'",
|
||||
verb,
|
||||
fields.join(", "),
|
||||
color_text(title, "green")
|
||||
color_text(title, Color::Green)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -768,7 +769,7 @@ fn ask_which_criterion(criteria: &[Criterion], title: &str) -> Result<usize> {
|
||||
));
|
||||
}
|
||||
|
||||
println!("Acceptance criteria of '{}':", color_text(title, "green"));
|
||||
println!("Acceptance criteria of '{}':", color_text(title, Color::Green));
|
||||
println!("{}", listing);
|
||||
// Either form, since find_criteria takes both.
|
||||
print!("Number or text: ");
|
||||
@@ -850,7 +851,7 @@ pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
|
||||
println!(
|
||||
"Already {}: {}",
|
||||
verb,
|
||||
color_text(&criterion.text, "green")
|
||||
color_text(&criterion.text, Color::Green)
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
@@ -863,7 +864,7 @@ pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
|
||||
"{} {}: {}",
|
||||
if checked { "Checked" } else { "Unchecked" },
|
||||
chosen + 1,
|
||||
color_text(&criterion.text, "green")
|
||||
color_text(&criterion.text, Color::Green)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+122
-12
@@ -3,6 +3,7 @@ use clap::Parser;
|
||||
|
||||
mod command;
|
||||
mod handlers;
|
||||
mod tui;
|
||||
mod util;
|
||||
|
||||
use command::*;
|
||||
@@ -36,8 +37,10 @@ fn main() -> Result<()> {
|
||||
let start = std::env::current_dir()?;
|
||||
|
||||
match cli.command {
|
||||
Command::Init => cmd_init(&start),
|
||||
Command::Add {
|
||||
// No subcommand opens the board, the way a bare `frig` does.
|
||||
None | Some(Command::Tui) => run_tui(&start),
|
||||
Some(Command::Init) => cmd_init(&start),
|
||||
Some(Command::Add {
|
||||
title,
|
||||
description,
|
||||
acceptance,
|
||||
@@ -46,7 +49,7 @@ fn main() -> Result<()> {
|
||||
due,
|
||||
owner,
|
||||
priority,
|
||||
} => cmd_add(
|
||||
}) => cmd_add(
|
||||
&title,
|
||||
&description,
|
||||
&acceptance,
|
||||
@@ -57,23 +60,130 @@ fn main() -> Result<()> {
|
||||
priority,
|
||||
&start,
|
||||
),
|
||||
Command::Ls { status, priority } => {
|
||||
Some(Command::Ls { status, priority }) => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_ls(&status, priority, &worklane_dir)
|
||||
}
|
||||
Command::Show { id } => {
|
||||
Some(Command::Show { id }) => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_show(&id, &worklane_dir)
|
||||
}
|
||||
Command::Mv {
|
||||
Some(Command::Mv {
|
||||
ticket,
|
||||
status,
|
||||
force,
|
||||
} => cmd_mv(&ticket, &status, force, &start),
|
||||
Command::Set(args) => cmd_set(&args, &start),
|
||||
Command::Append(args) => cmd_append(&args, &start),
|
||||
Command::Check(args) => cmd_check(&args, true, &start),
|
||||
Command::Uncheck(args) => cmd_check(&args, false, &start),
|
||||
Command::Comment { ticket, body, owner } => cmd_comment(&ticket, &body, &owner, &start),
|
||||
}) => cmd_mv(&ticket, &status, force, &start),
|
||||
Some(Command::Set(args)) => cmd_set(&args, &start),
|
||||
Some(Command::Append(args)) => cmd_append(&args, &start),
|
||||
Some(Command::Check(args)) => cmd_check(&args, true, &start),
|
||||
Some(Command::Uncheck(args)) => cmd_check(&args, false, &start),
|
||||
Some(Command::Comment {
|
||||
ticket,
|
||||
body,
|
||||
owner,
|
||||
}) => cmd_comment(&ticket, &body, &owner, &start),
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------- tui --
|
||||
|
||||
/// Restore the terminal whatever happens.
|
||||
///
|
||||
/// A panic inside the draw loop with raw mode still on leaves the shell unusable and
|
||||
/// the backtrace unreadable, so the hook runs before the default one.
|
||||
fn install_panic_hook() {
|
||||
let previous = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |info| {
|
||||
let _ = restore_terminal();
|
||||
previous(info);
|
||||
}));
|
||||
}
|
||||
|
||||
fn restore_terminal() -> std::io::Result<()> {
|
||||
crossterm::terminal::disable_raw_mode()?;
|
||||
crossterm::execute!(
|
||||
std::io::stdout(),
|
||||
crossterm::terminal::LeaveAlternateScreen
|
||||
)
|
||||
}
|
||||
|
||||
fn run_tui(start: &std::path::Path) -> Result<()> {
|
||||
use crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers};
|
||||
use std::io::IsTerminal;
|
||||
|
||||
// The board is looked for before the terminal is, so running this outside a
|
||||
// worklane directory gives the same message every other command gives rather than
|
||||
// a complaint about the terminal.
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
|
||||
// Without this, entering raw mode on a pipe fails with a bare "No such device or
|
||||
// address (os error 6)", which says nothing about the actual mistake. A bare
|
||||
// `worklane` is how the board is opened, so a script that reaches it by accident
|
||||
// has to be pointed at a subcommand.
|
||||
if !std::io::stdin().is_terminal() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"`worklane` with no subcommand opens the board, which needs a terminal.\n\
|
||||
For scripted use try `worklane ls` or `worklane show`; `worklane --help` \
|
||||
lists everything."
|
||||
));
|
||||
}
|
||||
|
||||
let mut board = tui::Board::new(&worklane_dir)?;
|
||||
|
||||
install_panic_hook();
|
||||
crossterm::terminal::enable_raw_mode()?;
|
||||
crossterm::execute!(std::io::stdout(), crossterm::terminal::EnterAlternateScreen)?;
|
||||
let mut terminal =
|
||||
ratatui::Terminal::new(ratatui::backend::CrosstermBackend::new(std::io::stdout()))?;
|
||||
|
||||
let result = (|| -> Result<()> {
|
||||
while !board.should_quit {
|
||||
board.tick()?;
|
||||
terminal.draw(|frame| tui::draw(frame, &board))?;
|
||||
|
||||
// Taken after the draw, so a scroll measures the overlay that is on screen.
|
||||
let screen = terminal.size()?;
|
||||
|
||||
// Bounded, so the tick still runs when nobody is typing.
|
||||
if !event::poll(tui::POLL)? {
|
||||
continue;
|
||||
}
|
||||
let Event::Key(key) = event::read()? else {
|
||||
continue;
|
||||
};
|
||||
if key.kind != KeyEventKind::Press {
|
||||
continue;
|
||||
}
|
||||
|
||||
match key.code {
|
||||
KeyCode::Char('q') => board.should_quit = true,
|
||||
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
board.should_quit = true
|
||||
}
|
||||
// Esc closes the detail view, and only quits when there is nothing
|
||||
// left to dismiss.
|
||||
KeyCode::Esc => match board.detail {
|
||||
Some(_) => board.toggle_detail(),
|
||||
None => board.should_quit = true,
|
||||
},
|
||||
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_detail(),
|
||||
KeyCode::Left | KeyCode::Char('h') => board.select_column(-1),
|
||||
KeyCode::Right | KeyCode::Char('l') => board.select_column(1),
|
||||
// Up and down stay on the selection, open detail view or not, so a
|
||||
// column can be read through without closing the modal. Scrolling the
|
||||
// open ticket is a page at a time.
|
||||
KeyCode::Up | KeyCode::Char('k') => board.select_card(-1),
|
||||
KeyCode::Down | KeyCode::Char('j') => board.select_card(1),
|
||||
KeyCode::PageUp => board.scroll_detail(-1, screen),
|
||||
KeyCode::PageDown => board.scroll_detail(1, screen),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})();
|
||||
|
||||
// Before the error surfaces, so a failure does not leave the shell in raw mode.
|
||||
restore_terminal()?;
|
||||
result
|
||||
}
|
||||
|
||||
+964
@@ -0,0 +1,964 @@
|
||||
//! The board as four columns, redrawn when the tree underneath it moves.
|
||||
//!
|
||||
//! Modelled on frig's TUI: event poll on a short timeout so timed work still runs when
|
||||
//! nobody is typing, state refreshed on a tick, and the terminal restored whatever
|
||||
//! happens.
|
||||
//!
|
||||
//! **Read only.** Moving a card by keypress is a follow-up. Everything here observes.
|
||||
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use anyhow::Result;
|
||||
use ratatui::layout::{Constraint, Direction, Layout, Margin, Rect, Size};
|
||||
use ratatui::style::{Modifier, Style};
|
||||
use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Block, Borders, Clear, Paragraph, Wrap};
|
||||
use ratatui::Frame;
|
||||
|
||||
use crate::handlers::read_comments;
|
||||
use crate::util::*;
|
||||
|
||||
/// How long the event poll waits before letting the tick run.
|
||||
pub const POLL: Duration = Duration::from_millis(250);
|
||||
|
||||
/// One status and the tickets in it.
|
||||
pub struct Column {
|
||||
pub status: &'static str,
|
||||
pub tickets: Vec<TicketItem>,
|
||||
}
|
||||
|
||||
/// What is on screen.
|
||||
pub struct Board {
|
||||
pub columns: Vec<Column>,
|
||||
pub column: usize,
|
||||
pub card: usize,
|
||||
/// The body and comments of the selected ticket, when the detail view is open.
|
||||
pub detail: Option<String>,
|
||||
/// First visible line of the detail view, counted in wrapped lines.
|
||||
pub offset: u16,
|
||||
pub should_quit: bool,
|
||||
worklane_dir: PathBuf,
|
||||
digest: u64,
|
||||
}
|
||||
|
||||
impl Board {
|
||||
pub fn new(worklane_dir: &Path) -> Result<Self> {
|
||||
let mut board = Board {
|
||||
columns: Vec::new(),
|
||||
column: 0,
|
||||
card: 0,
|
||||
detail: None,
|
||||
offset: 0,
|
||||
should_quit: false,
|
||||
worklane_dir: worklane_dir.to_path_buf(),
|
||||
digest: 0,
|
||||
};
|
||||
board.reload()?;
|
||||
Ok(board)
|
||||
}
|
||||
|
||||
/// Re-read the tree only when the digest says it moved.
|
||||
///
|
||||
/// The scan is the expensive part, not the draw, so this is what the tick guards.
|
||||
/// ratatui diffs its buffer, so drawing every iteration costs nothing.
|
||||
pub fn tick(&mut self) -> Result<bool> {
|
||||
let now = digest(&self.worklane_dir);
|
||||
if now == self.digest {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
self.reload()?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn reload(&mut self) -> Result<()> {
|
||||
self.columns = status_dirs()
|
||||
.into_iter()
|
||||
.map(|status| {
|
||||
let path = self.worklane_dir.join(status);
|
||||
// An absent or unreadable directory is an empty column, not a missing
|
||||
// one: the four statuses are the shape of the board.
|
||||
let tickets = collect_ticket_items(&path).unwrap_or_default();
|
||||
Column { status, tickets }
|
||||
})
|
||||
.collect();
|
||||
|
||||
self.digest = digest(&self.worklane_dir);
|
||||
self.clamp();
|
||||
|
||||
// The selected ticket may have moved or gone, so the open detail follows it.
|
||||
// The scroll offset stays where the reader put it: an edit elsewhere in the tree
|
||||
// should not throw them back to the top of what they are reading. A ticket that
|
||||
// got shorter is caught by the clamp in the draw.
|
||||
if self.detail.is_some() {
|
||||
self.detail = self.selected().map(detail_of);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Keep the selection on a card that exists, after the board changes under it.
|
||||
fn clamp(&mut self) {
|
||||
if self.columns.is_empty() {
|
||||
self.column = 0;
|
||||
self.card = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
self.column = self.column.min(self.columns.len() - 1);
|
||||
let count = self.columns[self.column].tickets.len();
|
||||
self.card = match count {
|
||||
0 => 0,
|
||||
count => self.card.min(count - 1),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn selected(&self) -> Option<&TicketItem> {
|
||||
self.columns
|
||||
.get(self.column)
|
||||
.and_then(|column| column.tickets.get(self.card))
|
||||
}
|
||||
|
||||
/// Move between columns, keeping the card index where it can land.
|
||||
pub fn select_column(&mut self, delta: isize) {
|
||||
if self.columns.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let last = self.columns.len() as isize - 1;
|
||||
let next = (self.column as isize + delta).clamp(0, last);
|
||||
self.column = next as usize;
|
||||
self.clamp();
|
||||
self.refresh_detail();
|
||||
}
|
||||
|
||||
pub fn select_card(&mut self, delta: isize) {
|
||||
let count = match self.columns.get(self.column) {
|
||||
Some(column) => column.tickets.len(),
|
||||
None => return,
|
||||
};
|
||||
if count == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
let next = (self.card as isize + delta).clamp(0, count as isize - 1);
|
||||
self.card = next as usize;
|
||||
self.refresh_detail();
|
||||
}
|
||||
|
||||
/// Open the detail view on the selected card, or close it if it is already open.
|
||||
pub fn toggle_detail(&mut self) {
|
||||
self.offset = 0;
|
||||
self.detail = match self.detail {
|
||||
Some(_) => None,
|
||||
None => self.selected().map(detail_of),
|
||||
};
|
||||
}
|
||||
|
||||
/// Scroll the open detail view by whole screenfuls, one line kept for overlap.
|
||||
///
|
||||
/// Up and down move the selection, so the scroll is on PageUp and PageDown. That is
|
||||
/// worth keeping either way: with the modal open, up and down step through the
|
||||
/// tickets and the modal follows, so a column can be read without closing it.
|
||||
///
|
||||
/// Clamped against the wrapped text rather than the raw lines, so the last page ends
|
||||
/// with the ticket instead of running on into blank space, and against zero at the
|
||||
/// top. The screen is asked for because both ends belong to the overlay, which only
|
||||
/// the draw otherwise measures.
|
||||
pub fn scroll_detail(&mut self, pages: isize, screen: Size) {
|
||||
let Some(detail) = &self.detail else { return };
|
||||
|
||||
let text = detail_text_area(Rect::new(0, 0, screen.width, screen.height));
|
||||
// A screenful less a line, so the eye has something to land on after the jump.
|
||||
let step = text.height.saturating_sub(1).max(1) as isize;
|
||||
let last = last_offset(detail, text) as isize;
|
||||
|
||||
self.offset = (self.offset as isize + pages.saturating_mul(step)).clamp(0, last) as u16;
|
||||
}
|
||||
|
||||
fn refresh_detail(&mut self) {
|
||||
// A newly selected ticket starts at its top, not partway down where the last one
|
||||
// was left.
|
||||
self.offset = 0;
|
||||
if self.detail.is_some() {
|
||||
self.detail = self.selected().map(detail_of);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The whole ticket as plain text: the body as `show` renders it, then the comments.
|
||||
///
|
||||
/// Plain rather than coloured, since ratatui draws styled spans and an escape sequence
|
||||
/// in a paragraph would be printed as literal bytes.
|
||||
fn detail_of(ticket: &TicketItem) -> String {
|
||||
let content = std::fs::read_to_string(&ticket.path).unwrap_or_default();
|
||||
let mut out = content_trim(&content, false);
|
||||
|
||||
let uuid = parse_ticket_field(&content, "ID");
|
||||
let comments = match ticket.path.parent().and_then(|status| status.parent()) {
|
||||
Some(worklane_dir) => {
|
||||
read_comments(&worklane_dir.join("comments").join(&uuid)).unwrap_or_default()
|
||||
}
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
out.push('\n');
|
||||
out.push_str(&format_comments_with(&comments, false));
|
||||
out
|
||||
}
|
||||
|
||||
/// A fingerprint of every ticket and comment file: name, length and modified time.
|
||||
///
|
||||
/// Names alone would miss a ticket edited in place, and a directory's own mtime only
|
||||
/// moves on create and rename, so watching the directories would miss it too. Comment
|
||||
/// files are included because a comment added elsewhere has to reach the detail view.
|
||||
///
|
||||
/// Cheap enough on a tree of tens of small files that it needs no new dependency. If it
|
||||
/// ever stops being cheap, `notify` is the next step, and the reason belongs on the
|
||||
/// ticket.
|
||||
pub fn digest(worklane_dir: &Path) -> u64 {
|
||||
let mut entries: Vec<(String, u64, Duration)> = Vec::new();
|
||||
|
||||
let mut visit = |dir: PathBuf| {
|
||||
let Ok(read) = std::fs::read_dir(&dir) else {
|
||||
return;
|
||||
};
|
||||
|
||||
for entry in read.filter_map(|e| e.ok()) {
|
||||
let path = entry.path();
|
||||
if path.extension().is_none_or(|e| e != "md") {
|
||||
continue;
|
||||
}
|
||||
let Ok(meta) = entry.metadata() else { continue };
|
||||
let modified = meta
|
||||
.modified()
|
||||
.ok()
|
||||
.and_then(|at| at.duration_since(SystemTime::UNIX_EPOCH).ok())
|
||||
.unwrap_or_default();
|
||||
|
||||
entries.push((path.to_string_lossy().to_string(), meta.len(), modified));
|
||||
}
|
||||
};
|
||||
|
||||
for status in status_dirs() {
|
||||
visit(worklane_dir.join(status));
|
||||
}
|
||||
|
||||
// Comments live one level deeper, a directory per ticket.
|
||||
let comments = worklane_dir.join("comments");
|
||||
if let Ok(read) = std::fs::read_dir(&comments) {
|
||||
for entry in read.filter_map(|e| e.ok()) {
|
||||
visit(entry.path());
|
||||
}
|
||||
}
|
||||
|
||||
// Sorted, so a directory handing entries back in a different order is not a change.
|
||||
entries.sort();
|
||||
|
||||
let mut hasher = DefaultHasher::new();
|
||||
entries.hash(&mut hasher);
|
||||
hasher.finish()
|
||||
}
|
||||
|
||||
pub fn draw(frame: &mut Frame, board: &Board) {
|
||||
let area = frame.area();
|
||||
let rows = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Min(3), Constraint::Length(1)])
|
||||
.split(area);
|
||||
|
||||
draw_columns(frame, board, rows[0]);
|
||||
draw_footer(frame, board, rows[1]);
|
||||
|
||||
if let Some(detail) = &board.detail {
|
||||
draw_detail(frame, detail, board.offset, area);
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_columns(frame: &mut Frame, board: &Board, area: Rect) {
|
||||
let widths: Vec<Constraint> = board
|
||||
.columns
|
||||
.iter()
|
||||
.map(|_| Constraint::Ratio(1, board.columns.len().max(1) as u32))
|
||||
.collect();
|
||||
|
||||
let areas = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints(widths)
|
||||
.split(area);
|
||||
|
||||
for (index, column) in board.columns.iter().enumerate() {
|
||||
let focused = index == board.column;
|
||||
let title = format!(" {} ({}) ", column.status, column.tickets.len());
|
||||
|
||||
let block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.title(Span::styled(
|
||||
title,
|
||||
Style::default()
|
||||
.fg(Color::Orange.into())
|
||||
.add_modifier(if focused {
|
||||
Modifier::BOLD
|
||||
} else {
|
||||
Modifier::empty()
|
||||
}),
|
||||
))
|
||||
.border_style(Style::default().fg(if focused {
|
||||
Color::Cyan.into()
|
||||
} else {
|
||||
Color::Grey.into()
|
||||
}));
|
||||
|
||||
let mut lines: Vec<Line> = Vec::new();
|
||||
for (card, ticket) in column.tickets.iter().enumerate() {
|
||||
let selected = focused && card == board.card;
|
||||
lines.extend(card_lines(ticket, selected));
|
||||
}
|
||||
|
||||
// An empty status is an empty column, not a column that is not there.
|
||||
frame.render_widget(Paragraph::new(lines).block(block), areas[index]);
|
||||
}
|
||||
}
|
||||
|
||||
/// One card: the priority mark and short id, the title, then owner and due.
|
||||
fn card_lines(ticket: &TicketItem, selected: bool) -> Vec<Line<'static>> {
|
||||
let (glyph, colour) = priority_mark(ticket.priority);
|
||||
let emphasis = if selected {
|
||||
Modifier::REVERSED
|
||||
} else {
|
||||
Modifier::empty()
|
||||
};
|
||||
|
||||
vec![
|
||||
Line::from(vec![
|
||||
Span::styled(
|
||||
glyph.to_string(),
|
||||
Style::default().fg(colour.into()).add_modifier(emphasis),
|
||||
),
|
||||
Span::raw(" "),
|
||||
Span::styled(
|
||||
format!("({})", ticket.id),
|
||||
Style::default()
|
||||
.fg(Color::Red.into())
|
||||
.add_modifier(emphasis),
|
||||
),
|
||||
]),
|
||||
Line::from(Span::styled(
|
||||
ticket.title.clone(),
|
||||
Style::default().add_modifier(emphasis),
|
||||
)),
|
||||
Line::from(Span::styled(
|
||||
format!("{} · {}", ticket.owner, ticket.due),
|
||||
Style::default().fg(Color::Grey.into()),
|
||||
)),
|
||||
Line::from(""),
|
||||
]
|
||||
}
|
||||
|
||||
fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) {
|
||||
let keys = match board.detail {
|
||||
Some(_) => " ←→↑↓ select pgup/pgdn scroll enter close q quit ",
|
||||
None => " ←→ column ↑↓ card enter detail q quit ",
|
||||
};
|
||||
|
||||
frame.render_widget(
|
||||
Paragraph::new(Span::styled(keys, Style::default().fg(Color::Grey.into()))),
|
||||
area,
|
||||
);
|
||||
}
|
||||
|
||||
/// Where the detail overlay sits in the frame.
|
||||
///
|
||||
/// Inset, so the board stays visible around the edges and the overlay reads as one.
|
||||
fn detail_overlay(area: Rect) -> Rect {
|
||||
let width = area.width.saturating_sub(area.width / 5).max(20);
|
||||
let height = area.height.saturating_sub(area.height / 6).max(6);
|
||||
Rect {
|
||||
x: area.x + (area.width.saturating_sub(width)) / 2,
|
||||
y: area.y + (area.height.saturating_sub(height)) / 2,
|
||||
width: width.min(area.width),
|
||||
height: height.min(area.height),
|
||||
}
|
||||
}
|
||||
|
||||
/// The part of the overlay that holds text: the border takes a row and a column on
|
||||
/// either side, and the title sits on the top border rather than below it.
|
||||
fn detail_text_area(area: Rect) -> Rect {
|
||||
detail_overlay(area).inner(Margin::new(1, 1))
|
||||
}
|
||||
|
||||
/// The furthest the detail view can scroll: the last screenful, and no further.
|
||||
///
|
||||
/// Measured by the widget rather than counted by hand, since it wraps on words. A clamp
|
||||
/// on the raw lines would stop short of the end on a wrapped ticket, and one that
|
||||
/// ignored the wrapping the other way would scroll past it into blank space.
|
||||
fn last_offset(detail: &str, text: Rect) -> u16 {
|
||||
let wrapped = Paragraph::new(detail)
|
||||
.wrap(Wrap { trim: false })
|
||||
.line_count(text.width);
|
||||
|
||||
u16::try_from(wrapped)
|
||||
.unwrap_or(u16::MAX)
|
||||
.saturating_sub(text.height)
|
||||
}
|
||||
|
||||
fn draw_detail(frame: &mut Frame, detail: &str, offset: u16, area: Rect) {
|
||||
let overlay = detail_overlay(area);
|
||||
|
||||
// Clamped here as well as on the keypress: the terminal may have been resized since,
|
||||
// and a ticket read to its end can grow shorter under a tick.
|
||||
let offset = offset.min(last_offset(detail, detail_text_area(area)));
|
||||
|
||||
let block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_style(Style::default().fg(Color::Cyan.into()))
|
||||
.title(Span::styled(
|
||||
" ticket ",
|
||||
Style::default().fg(Color::Orange.into()),
|
||||
));
|
||||
|
||||
frame.render_widget(Clear, overlay);
|
||||
frame.render_widget(
|
||||
Paragraph::new(detail.to_string())
|
||||
.block(block)
|
||||
.wrap(Wrap { trim: false })
|
||||
.scroll((offset, 0)),
|
||||
overlay,
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ratatui::Terminal;
|
||||
use ratatui::backend::TestBackend;
|
||||
|
||||
/// A board on disk, since everything here is about reading a real tree.
|
||||
fn board_dir() -> PathBuf {
|
||||
let dir = std::env::temp_dir().join(format!("worklane-tui-{}", uuid::Uuid::new_v4()));
|
||||
for status in status_dirs() {
|
||||
std::fs::create_dir_all(dir.join(status)).unwrap();
|
||||
}
|
||||
dir
|
||||
}
|
||||
|
||||
fn write_ticket(dir: &Path, status: &str, uuid: &str, title: &str, extra: &str) -> PathBuf {
|
||||
let path = dir.join(status).join(format!("{}_{}.md", uuid, slug(title)));
|
||||
std::fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"# {title}\n\n## Description\nA description.\n\n## Acceptance Criteria\n\
|
||||
- [ ] Crit one\n\n## Metadata\n\n- **ID**: {uuid}\n- **Priority**: 2\n\
|
||||
- **Tags**: _None_\n- **Due**: 2026-12-31\n- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:00:00\n- **Status**: {status}\n{extra}"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
path
|
||||
}
|
||||
|
||||
/// A section of numbered lines, so a test can say which of them is on screen.
|
||||
///
|
||||
/// Long enough not to fit any overlay the tests draw, which is true of every real
|
||||
/// ticket in the repo as well.
|
||||
fn long_section(lines: usize) -> String {
|
||||
let body: String = (1..=lines).map(|n| format!("Line {n:03}\n")).collect();
|
||||
format!("\n## Notes\n{body}")
|
||||
}
|
||||
|
||||
/// The screen the scrolling tests draw on, so the keypress and the draw measure the
|
||||
/// same overlay.
|
||||
const SCREEN: Size = Size {
|
||||
width: 120,
|
||||
height: 20,
|
||||
};
|
||||
|
||||
/// The rendered buffer as lines of text, escapes and styling dropped.
|
||||
fn render(board: &Board, width: u16, height: u16) -> Vec<String> {
|
||||
let mut terminal = Terminal::new(TestBackend::new(width, height)).unwrap();
|
||||
terminal.draw(|frame| draw(frame, board)).unwrap();
|
||||
|
||||
let buffer = terminal.backend().buffer().clone();
|
||||
(0..buffer.area.height)
|
||||
.map(|y| {
|
||||
(0..buffer.area.width)
|
||||
.map(|x| buffer[(x, y)].symbol())
|
||||
.collect::<String>()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_board_draws_the_four_statuses_as_columns() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
write_ticket(&dir, "committed", "22222222-0000-4000-8000-000000000000", "Second one", "");
|
||||
|
||||
let board = Board::new(&dir).unwrap();
|
||||
let screen = render(&board, 120, 20).join("\n");
|
||||
|
||||
for heading in ["backlog (1)", "committed (1)", "reviewing (0)", "done (0)"] {
|
||||
assert!(screen.contains(heading), "no {heading:?} in:\n{screen}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The card has to carry enough to identify the ticket without opening it.
|
||||
#[test]
|
||||
fn a_card_shows_the_short_id_title_owner_and_due() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
let board = Board::new(&dir).unwrap();
|
||||
let screen = render(&board, 120, 20).join("\n");
|
||||
|
||||
assert!(screen.contains("(1111111)"), "no short id in:\n{screen}");
|
||||
assert!(screen.contains("First one"), "no title in:\n{screen}");
|
||||
assert!(screen.contains("alice"), "no owner in:\n{screen}");
|
||||
assert!(screen.contains("2026-12-31"), "no due date in:\n{screen}");
|
||||
}
|
||||
|
||||
/// An empty status is a column with nothing in it, not a column that is missing.
|
||||
#[test]
|
||||
fn an_empty_status_renders_as_an_empty_column() {
|
||||
let dir = board_dir();
|
||||
|
||||
let board = Board::new(&dir).unwrap();
|
||||
assert_eq!(board.columns.len(), 4);
|
||||
|
||||
let screen = render(&board, 120, 20).join("\n");
|
||||
for status in status_dirs() {
|
||||
assert!(screen.contains(&format!("{status} (0)")), "{screen}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Even with a status directory absent altogether, the board keeps its shape.
|
||||
#[test]
|
||||
fn a_missing_status_directory_is_still_a_column() {
|
||||
let dir = board_dir();
|
||||
std::fs::remove_dir_all(dir.join("done")).unwrap();
|
||||
|
||||
let board = Board::new(&dir).unwrap();
|
||||
assert_eq!(board.columns.len(), 4);
|
||||
assert!(render(&board, 120, 20).join("\n").contains("done (0)"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_digest_is_stable_when_nothing_changes() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
assert_eq!(digest(&dir), digest(&dir));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_digest_moves_when_a_ticket_is_created_or_moved() {
|
||||
let dir = board_dir();
|
||||
let before = digest(&dir);
|
||||
|
||||
let path = write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
let created = digest(&dir);
|
||||
assert_ne!(before, created, "a new ticket went unnoticed");
|
||||
|
||||
let moved = dir.join("committed").join(path.file_name().unwrap());
|
||||
std::fs::rename(&path, &moved).unwrap();
|
||||
assert_ne!(created, digest(&dir), "a moved ticket went unnoticed");
|
||||
|
||||
std::fs::remove_file(&moved).unwrap();
|
||||
assert_eq!(before, digest(&dir), "a deleted ticket left a trace");
|
||||
}
|
||||
|
||||
/// The case a directory watch would miss: no create, no rename, only the body.
|
||||
#[test]
|
||||
fn the_digest_moves_when_a_ticket_is_edited_in_place() {
|
||||
let dir = board_dir();
|
||||
let path = write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
let before = digest(&dir);
|
||||
|
||||
let content = std::fs::read_to_string(&path).unwrap();
|
||||
std::fs::write(&path, content.replace("A description.", "A longer description.")).unwrap();
|
||||
|
||||
assert_ne!(before, digest(&dir), "an in-place edit went unnoticed");
|
||||
}
|
||||
|
||||
/// And the harder half of it: an edit that does not change the length either, so
|
||||
/// only the modified time gives it away.
|
||||
#[test]
|
||||
fn the_digest_moves_on_an_edit_of_the_same_length() {
|
||||
let dir = board_dir();
|
||||
let path = write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
let content = std::fs::read_to_string(&path).unwrap();
|
||||
let same_length = content.replace("A description.", "A descriptionA");
|
||||
assert_eq!(content.len(), same_length.len(), "the fixture changed length");
|
||||
std::fs::write(&path, &same_length).unwrap();
|
||||
|
||||
let before = digest(&dir);
|
||||
|
||||
// Stamped rather than slept on, so the test does not depend on how coarse the
|
||||
// filesystem's timestamps are.
|
||||
let file = std::fs::File::options().write(true).open(&path).unwrap();
|
||||
file.set_modified(SystemTime::UNIX_EPOCH + Duration::from_secs(1_800_000_000))
|
||||
.unwrap();
|
||||
|
||||
assert_ne!(before, digest(&dir), "a same-length edit went unnoticed");
|
||||
}
|
||||
|
||||
/// A comment added elsewhere has to reach the detail view, so it counts as a change.
|
||||
#[test]
|
||||
fn the_digest_moves_when_a_comment_is_added() {
|
||||
let dir = board_dir();
|
||||
let uuid = "11111111-0000-4000-8000-000000000000";
|
||||
write_ticket(&dir, "backlog", uuid, "First one", "");
|
||||
let before = digest(&dir);
|
||||
|
||||
let comments = dir.join("comments").join(uuid);
|
||||
std::fs::create_dir_all(&comments).unwrap();
|
||||
std::fs::write(
|
||||
comments.join("20260821_120000_000000.md"),
|
||||
"**Comment**\nA note from elsewhere.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_ne!(before, digest(&dir), "a new comment went unnoticed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_moves_between_columns_and_cards() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "Alpha", "");
|
||||
write_ticket(&dir, "backlog", "22222222-0000-4000-8000-000000000000", "Beta", "");
|
||||
write_ticket(&dir, "committed", "33333333-0000-4000-8000-000000000000", "Gamma", "");
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Alpha".to_string()));
|
||||
|
||||
board.select_card(1);
|
||||
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Beta".to_string()));
|
||||
|
||||
// Clamped at both ends rather than wrapping
|
||||
board.select_card(5);
|
||||
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Beta".to_string()));
|
||||
board.select_card(-9);
|
||||
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Alpha".to_string()));
|
||||
|
||||
board.select_column(1);
|
||||
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Gamma".to_string()));
|
||||
|
||||
// reviewing is empty, so there is nothing selected there
|
||||
board.select_column(1);
|
||||
assert!(board.selected().is_none());
|
||||
|
||||
board.select_column(-9);
|
||||
assert_eq!(board.column, 0);
|
||||
}
|
||||
|
||||
/// Moving from a column with three cards to one with one must not leave the
|
||||
/// selection pointing past the end.
|
||||
#[test]
|
||||
fn the_card_index_is_clamped_when_the_column_is_shorter() {
|
||||
let dir = board_dir();
|
||||
for (n, title) in [("11111111", "Alpha"), ("22222222", "Beta"), ("33333333", "Gamma")] {
|
||||
write_ticket(&dir, "backlog", &format!("{n}-0000-4000-8000-000000000000"), title, "");
|
||||
}
|
||||
write_ticket(&dir, "committed", "44444444-0000-4000-8000-000000000000", "Delta", "");
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.select_card(2);
|
||||
board.select_column(1);
|
||||
|
||||
assert_eq!(board.card, 0);
|
||||
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Delta".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_detail_view_shows_the_body_and_the_comments() {
|
||||
let dir = board_dir();
|
||||
let uuid = "11111111-0000-4000-8000-000000000000";
|
||||
write_ticket(&dir, "backlog", uuid, "First one", "");
|
||||
|
||||
let comments = dir.join("comments").join(uuid);
|
||||
std::fs::create_dir_all(&comments).unwrap();
|
||||
std::fs::write(
|
||||
comments.join("20260821_120000_000000.md"),
|
||||
"**Comment**\nA note from elsewhere.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
assert!(board.detail.is_none());
|
||||
|
||||
board.toggle_detail();
|
||||
let detail = board.detail.clone().expect("no detail");
|
||||
|
||||
assert!(detail.contains("A description."), "{detail}");
|
||||
assert!(detail.contains("Crit one"), "{detail}");
|
||||
assert!(detail.contains("A note from elsewhere."), "{detail}");
|
||||
assert!(detail.contains("bob"), "{detail}");
|
||||
|
||||
// Plain text, since ratatui would print an escape as literal bytes
|
||||
assert!(!detail.contains('\x1b'), "escapes reached the detail view: {detail:?}");
|
||||
|
||||
board.toggle_detail();
|
||||
assert!(board.detail.is_none());
|
||||
}
|
||||
|
||||
/// A comment added while the detail view is open shows up on the next tick.
|
||||
#[test]
|
||||
fn a_tick_picks_up_a_comment_added_under_an_open_detail_view() {
|
||||
let dir = board_dir();
|
||||
let uuid = "11111111-0000-4000-8000-000000000000";
|
||||
write_ticket(&dir, "backlog", uuid, "First one", "");
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
assert!(!board.detail.clone().unwrap().contains("A late note."));
|
||||
|
||||
let comments = dir.join("comments").join(uuid);
|
||||
std::fs::create_dir_all(&comments).unwrap();
|
||||
std::fs::write(
|
||||
comments.join("20260821_120000_000000.md"),
|
||||
"**Comment**\nA late note.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(board.tick().unwrap(), "the tick saw no change");
|
||||
assert!(board.detail.clone().unwrap().contains("A late note."), "{:?}", board.detail);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_tick_with_nothing_changed_does_not_reload() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
assert!(!board.tick().unwrap());
|
||||
}
|
||||
|
||||
/// The reported bug: a ticket longer than the overlay had no way to be read past its
|
||||
/// first screenful, comments included.
|
||||
#[test]
|
||||
fn paging_down_reaches_the_end_of_a_long_ticket() {
|
||||
let dir = board_dir();
|
||||
let uuid = "11111111-0000-4000-8000-000000000000";
|
||||
write_ticket(&dir, "backlog", uuid, "First one", &long_section(60));
|
||||
|
||||
let comments = dir.join("comments").join(uuid);
|
||||
std::fs::create_dir_all(&comments).unwrap();
|
||||
std::fs::write(
|
||||
comments.join("20260821_120000_000000.md"),
|
||||
"**Comment**\nThe last word.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
|
||||
let top = render(&board, SCREEN.width, SCREEN.height).join("\n");
|
||||
assert!(top.contains("A description."), "not at the top:\n{top}");
|
||||
assert!(!top.contains("Line 060"), "the fixture is too short:\n{top}");
|
||||
|
||||
// More pages than the ticket has, since the clamp is what stops it.
|
||||
for _ in 0..20 {
|
||||
board.scroll_detail(1, SCREEN);
|
||||
}
|
||||
|
||||
let end = render(&board, SCREEN.width, SCREEN.height).join("\n");
|
||||
assert!(end.contains("Line 060"), "the end is out of reach:\n{end}");
|
||||
assert!(end.contains("The last word."), "the comments are out of reach:\n{end}");
|
||||
assert!(!end.contains("A description."), "nothing scrolled:\n{end}");
|
||||
}
|
||||
|
||||
/// The end of the scroll is the end of the text, not blank space past it, and the top
|
||||
/// of it is the top of the ticket.
|
||||
#[test]
|
||||
fn the_scroll_offset_stops_at_both_ends() {
|
||||
let dir = board_dir();
|
||||
write_ticket(
|
||||
&dir,
|
||||
"backlog",
|
||||
"11111111-0000-4000-8000-000000000000",
|
||||
"First one",
|
||||
&long_section(60),
|
||||
);
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
|
||||
for _ in 0..20 {
|
||||
board.scroll_detail(1, SCREEN);
|
||||
}
|
||||
let settled = board.offset;
|
||||
assert!(settled > 0, "a long ticket did not scroll at all");
|
||||
|
||||
board.scroll_detail(1, SCREEN);
|
||||
assert_eq!(board.offset, settled, "the offset ran past the end");
|
||||
|
||||
// The last screenful is full: text on the bottom row of the overlay, not the
|
||||
// blank space a clamp on the raw lines would have left there.
|
||||
let lines = render(&board, SCREEN.width, SCREEN.height);
|
||||
let text = detail_text_area(Rect::new(0, 0, SCREEN.width, SCREEN.height));
|
||||
let bottom: String = lines[(text.bottom() - 1) as usize]
|
||||
.chars()
|
||||
.skip(text.x as usize)
|
||||
.take(text.width as usize)
|
||||
.collect();
|
||||
assert!(
|
||||
!bottom.trim().is_empty(),
|
||||
"the last page ran into blank space:\n{}",
|
||||
lines.join("\n")
|
||||
);
|
||||
|
||||
board.scroll_detail(-40, SCREEN);
|
||||
assert_eq!(board.offset, 0, "the offset went above the top");
|
||||
}
|
||||
|
||||
/// A ticket that fits has nothing to scroll, so the keys do nothing to it.
|
||||
#[test]
|
||||
fn a_ticket_shorter_than_the_overlay_does_not_scroll() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
|
||||
|
||||
// Tall enough that the whole ticket is on screen at once.
|
||||
let roomy = Size {
|
||||
width: 120,
|
||||
height: 60,
|
||||
};
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
let before = render(&board, roomy.width, roomy.height);
|
||||
|
||||
board.scroll_detail(1, roomy);
|
||||
assert_eq!(board.offset, 0);
|
||||
assert_eq!(render(&board, roomy.width, roomy.height), before);
|
||||
}
|
||||
|
||||
/// Up and down still move the selection with the detail view open, and the modal
|
||||
/// follows, which is the reason the scroll went on pgup and pgdn in the first place.
|
||||
#[test]
|
||||
fn the_selection_still_moves_under_an_open_detail_view() {
|
||||
let dir = board_dir();
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "Alpha", "");
|
||||
write_ticket(&dir, "backlog", "22222222-0000-4000-8000-000000000000", "Beta", "");
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
// By id rather than title: the body leaves the title to the caller that prints
|
||||
// the heading, so the detail text does not carry it.
|
||||
assert!(board.detail.clone().unwrap().contains("11111111"), "{:?}", board.detail);
|
||||
|
||||
board.select_card(1);
|
||||
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Beta".to_string()));
|
||||
assert!(board.detail.clone().unwrap().contains("22222222"), "{:?}", board.detail);
|
||||
}
|
||||
|
||||
/// A newly selected ticket starts at its own top, not where the last one was left.
|
||||
#[test]
|
||||
fn the_scroll_offset_resets_when_the_selection_moves() {
|
||||
let dir = board_dir();
|
||||
let long = long_section(60);
|
||||
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "Alpha", &long);
|
||||
write_ticket(&dir, "backlog", "22222222-0000-4000-8000-000000000000", "Beta", &long);
|
||||
write_ticket(&dir, "committed", "33333333-0000-4000-8000-000000000000", "Gamma", &long);
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
|
||||
board.scroll_detail(1, SCREEN);
|
||||
assert!(board.offset > 0);
|
||||
board.select_card(1);
|
||||
assert_eq!(board.offset, 0, "the next card opened partway down");
|
||||
|
||||
board.scroll_detail(1, SCREEN);
|
||||
assert!(board.offset > 0);
|
||||
board.select_column(1);
|
||||
assert_eq!(board.offset, 0, "the next column opened partway down");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_scroll_offset_resets_when_the_detail_view_is_reopened() {
|
||||
let dir = board_dir();
|
||||
write_ticket(
|
||||
&dir,
|
||||
"backlog",
|
||||
"11111111-0000-4000-8000-000000000000",
|
||||
"First one",
|
||||
&long_section(60),
|
||||
);
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
board.scroll_detail(1, SCREEN);
|
||||
assert!(board.offset > 0);
|
||||
|
||||
board.toggle_detail();
|
||||
board.toggle_detail();
|
||||
assert_eq!(board.offset, 0, "the ticket reopened where it was left");
|
||||
}
|
||||
|
||||
/// An edit elsewhere in the tree must not throw the reader back to the top.
|
||||
#[test]
|
||||
fn a_tick_leaves_the_scroll_where_the_reader_put_it() {
|
||||
let dir = board_dir();
|
||||
let uuid = "11111111-0000-4000-8000-000000000000";
|
||||
write_ticket(&dir, "backlog", uuid, "First one", &long_section(60));
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
board.toggle_detail();
|
||||
board.scroll_detail(1, SCREEN);
|
||||
let offset = board.offset;
|
||||
|
||||
let comments = dir.join("comments").join(uuid);
|
||||
std::fs::create_dir_all(&comments).unwrap();
|
||||
std::fs::write(
|
||||
comments.join("20260821_120000_000000.md"),
|
||||
"**Comment**\nA late note.\n\n**Author**: bob\n**Time**: 2026-08-21 12:00:00\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(board.tick().unwrap(), "the tick saw no change");
|
||||
assert_eq!(board.offset, offset);
|
||||
}
|
||||
|
||||
/// The footer is what sent the reporter looking for their own mistake, so it has to
|
||||
/// name the keys that exist and only those.
|
||||
#[test]
|
||||
fn the_footer_names_the_keys_that_work() {
|
||||
let dir = board_dir();
|
||||
write_ticket(
|
||||
&dir,
|
||||
"backlog",
|
||||
"11111111-0000-4000-8000-000000000000",
|
||||
"First one",
|
||||
&long_section(60),
|
||||
);
|
||||
|
||||
let mut board = Board::new(&dir).unwrap();
|
||||
|
||||
let closed = render(&board, SCREEN.width, SCREEN.height).join("\n");
|
||||
assert!(closed.contains("↑↓ card"), "{closed}");
|
||||
assert!(closed.contains("enter detail"), "{closed}");
|
||||
assert!(!closed.contains("scroll"), "a scroll offered with nothing open:\n{closed}");
|
||||
|
||||
board.toggle_detail();
|
||||
let open = render(&board, SCREEN.width, SCREEN.height).join("\n");
|
||||
assert!(open.contains("pgup/pgdn scroll"), "{open}");
|
||||
assert!(open.contains("select"), "{open}");
|
||||
assert!(open.contains("enter close"), "{open}");
|
||||
}
|
||||
|
||||
/// The board and the listing draw from the same palette, so a colour cannot exist
|
||||
/// for one and not the other. The enum makes that a compile error; this pins the
|
||||
/// mapping itself.
|
||||
#[test]
|
||||
fn the_priority_marks_use_the_shared_palette() {
|
||||
for level in PRIORITY_RANGE {
|
||||
let (_, colour) = priority_mark(Priority::Level(level));
|
||||
let tui: ratatui::style::Color = colour.into();
|
||||
assert_ne!(tui, ratatui::style::Color::Reset, "level {level} has no colour");
|
||||
}
|
||||
}
|
||||
}
|
||||
+137
-56
@@ -52,24 +52,74 @@ pub fn should_use_colors() -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_color(color: &str) -> &'static str {
|
||||
match color {
|
||||
"red" => "\x1b[31m",
|
||||
"cyan" => "\x1b[36m",
|
||||
"orange" => "\x1b[33m",
|
||||
"green" => "\x1b[32m",
|
||||
// Indexed colour 8 in the 256-colour form, which is byte for byte what
|
||||
// crossterm emits for ratatui's Color::DarkGray, the grey frig and pantop
|
||||
// use for dimmed rows. Neither SGR 90 nor 37 renders as grey on every
|
||||
// palette: 90 leans on the bright-black slot and 37 can sit right on top
|
||||
// of the default foreground.
|
||||
"grey" => "\x1b[38;5;8m",
|
||||
// Bold, per the guideline in AGENTS.md. Its absence meant colorize_line
|
||||
// asked for a colour that did not exist and got an empty prefix.
|
||||
"magenta" => "\x1b[1;35m",
|
||||
// Indexed, for the same reason grey is: this is the spelling that renders.
|
||||
"brightred" => "\x1b[38;5;9m",
|
||||
_ => "",
|
||||
/// The palette, as a type rather than a set of strings.
|
||||
///
|
||||
/// One definition for both renderers. The CLI needs an escape sequence and the TUI
|
||||
/// needs a `ratatui::style::Color`, and an enum makes a colour that exists for one and
|
||||
/// not the other a compile error instead of something a test has to go looking for.
|
||||
/// The stringly-typed version needed exactly such a test, and a missing entry silently
|
||||
/// produced an empty prefix, which is how `magenta` came to be undefined.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Color {
|
||||
Red,
|
||||
Cyan,
|
||||
Orange,
|
||||
Green,
|
||||
Grey,
|
||||
Magenta,
|
||||
BrightRed,
|
||||
}
|
||||
|
||||
impl Color {
|
||||
/// The SGR sequence the CLI writes.
|
||||
pub fn ansi(self) -> &'static str {
|
||||
match self {
|
||||
Color::Red => "\x1b[31m",
|
||||
Color::Cyan => "\x1b[36m",
|
||||
Color::Orange => "\x1b[33m",
|
||||
Color::Green => "\x1b[32m",
|
||||
// Indexed colour 8 in the 256-colour form, which is byte for byte what
|
||||
// crossterm emits for ratatui's Color::DarkGray, the grey frig and pantop
|
||||
// use for dimmed rows. Neither SGR 90 nor 37 renders as grey on every
|
||||
// palette: 90 leans on the bright-black slot and 37 can sit right on top
|
||||
// of the default foreground.
|
||||
Color::Grey => "\x1b[38;5;8m",
|
||||
// Bold, per the guideline in AGENTS.md.
|
||||
Color::Magenta => "\x1b[1;35m",
|
||||
// Indexed, for the same reason grey is: this is the spelling that renders.
|
||||
Color::BrightRed => "\x1b[38;5;9m",
|
||||
}
|
||||
}
|
||||
|
||||
/// Every colour in the palette, so a test can walk them without listing them.
|
||||
pub const ALL: [Color; 7] = [
|
||||
Color::Red,
|
||||
Color::Cyan,
|
||||
Color::Orange,
|
||||
Color::Green,
|
||||
Color::Grey,
|
||||
Color::Magenta,
|
||||
Color::BrightRed,
|
||||
];
|
||||
}
|
||||
|
||||
/// The same palette as ratatui sees it.
|
||||
///
|
||||
/// Chosen to match what crossterm emits for the escape above, so a card in the TUI and
|
||||
/// a row in the listing are the same colour rather than two guesses at it.
|
||||
impl From<Color> for ratatui::style::Color {
|
||||
fn from(color: Color) -> Self {
|
||||
use ratatui::style::Color as Tui;
|
||||
|
||||
match color {
|
||||
Color::Red => Tui::Red,
|
||||
Color::Cyan => Tui::Cyan,
|
||||
Color::Orange => Tui::Yellow,
|
||||
Color::Green => Tui::Green,
|
||||
Color::Grey => Tui::DarkGray,
|
||||
Color::Magenta => Tui::Magenta,
|
||||
Color::BrightRed => Tui::LightRed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,15 +127,15 @@ pub fn get_color(color: &str) -> &'static str {
|
||||
///
|
||||
/// The seam matters for anything that aligns columns: a caller has to be able to
|
||||
/// render both ways in one process to prove the padding does not depend on it.
|
||||
pub fn paint(text: &str, color: &str, enabled: bool) -> String {
|
||||
pub fn paint(text: &str, color: Color, enabled: bool) -> String {
|
||||
if enabled {
|
||||
format!("{}{}{}", get_color(color), text, "\x1b[0m")
|
||||
format!("{}{}{}", color.ansi(), text, "\x1b[0m")
|
||||
} else {
|
||||
text.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn color_text(text: &str, color: &str) -> String {
|
||||
pub fn color_text(text: &str, color: Color) -> String {
|
||||
paint(text, color, should_use_colors())
|
||||
}
|
||||
|
||||
@@ -167,9 +217,9 @@ fn ambiguous(search: &str, matches: &[(String, String, String, String)]) -> anyh
|
||||
message.push_str(&format!(
|
||||
" {}. ({}) {} [{}]\n",
|
||||
i + 1,
|
||||
color_text(short_id(id), "red"),
|
||||
color_text(short_id(id), Color::Red),
|
||||
title,
|
||||
color_text(status, "orange"),
|
||||
color_text(status, Color::Orange),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -263,18 +313,26 @@ pub fn resolve_ticket(search: &str, worklane_dir: &Path) -> Result<(String, Stri
|
||||
Ok((status, title, content))
|
||||
}
|
||||
pub fn format_comments(comments: &[(String, String, String, String)]) -> String {
|
||||
format_comments_with(comments, should_use_colors())
|
||||
}
|
||||
|
||||
/// As above, with the colour decision passed in for the TUI.
|
||||
pub fn format_comments_with(
|
||||
comments: &[(String, String, String, String)],
|
||||
colored: bool,
|
||||
) -> String {
|
||||
if comments.is_empty() {
|
||||
return color_text("No comments yet.", "grey");
|
||||
return paint("No comments yet.", Color::Grey, colored);
|
||||
}
|
||||
|
||||
let mut result = String::new();
|
||||
result.push_str("\n");
|
||||
result.push_str(&color_text("COMMENTS", "orange"));
|
||||
result.push_str(&paint("COMMENTS", Color::Orange, colored));
|
||||
result.push_str(&format!("\n{}\n", "─".repeat(20)));
|
||||
|
||||
for (_filename, author, time, body) in comments {
|
||||
result.push_str("\n");
|
||||
result.push_str(&color_text(&format!("From {} ({})", author, time), "cyan"));
|
||||
result.push_str(&paint(&format!("From {} ({})", author, time), Color::Cyan, colored));
|
||||
result.push_str("\n");
|
||||
if !body.is_empty() {
|
||||
result.push_str(&" ".to_string());
|
||||
@@ -286,8 +344,15 @@ pub fn format_comments(comments: &[(String, String, String, String)]) -> String
|
||||
result
|
||||
}
|
||||
pub fn content_trim_colored(content: &str) -> String {
|
||||
content_trim(content, should_use_colors())
|
||||
}
|
||||
|
||||
/// The ticket body rendered for display, with the colour decision passed in.
|
||||
///
|
||||
/// The TUI needs the plain form: ratatui draws styled spans, and an escape sequence
|
||||
/// embedded in a paragraph would be printed as literal bytes.
|
||||
pub fn content_trim(content: &str, colored: bool) -> String {
|
||||
let lines: Vec<&str> = content.trim().lines().collect();
|
||||
let colored = should_use_colors();
|
||||
let mut result = String::new();
|
||||
let mut current_section = "";
|
||||
let mut criterion = 0;
|
||||
@@ -299,7 +364,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
// Track current section
|
||||
if let Some(section_name) = line.strip_prefix("## ") {
|
||||
current_section = line;
|
||||
result.push_str(&paint(section_name, "orange", colored));
|
||||
result.push_str(&paint(section_name, Color::Orange, colored));
|
||||
result.push('\n');
|
||||
// Measured on the name as displayed, in characters. The rule used to span
|
||||
// the raw line, so it ran three past the heading for the "## ", and byte
|
||||
@@ -350,15 +415,15 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
&& let Some((checked, text)) = checkbox(line)
|
||||
{
|
||||
criterion += 1;
|
||||
result.push_str(&paint(&format!("{}.", criterion), "cyan", colored));
|
||||
result.push_str(&paint(&format!("{}.", criterion), Color::Cyan, colored));
|
||||
result.push(' ');
|
||||
result.push_str(&paint(
|
||||
if checked { "[x]" } else { "[ ]" },
|
||||
"grey",
|
||||
Color::Grey,
|
||||
colored,
|
||||
));
|
||||
result.push(' ');
|
||||
result.push_str(&colorize_line(text));
|
||||
result.push_str(&colorize_bold(text, colored));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
@@ -371,7 +436,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
let link_start = start + end_bracket + 1;
|
||||
if let Some(end) = line[link_start..].find(']') {
|
||||
let absolute_end = link_start + end + 1;
|
||||
result.push_str(&color_text(&line[start..absolute_end], "cyan"));
|
||||
result.push_str(&paint(&line[start..absolute_end], Color::Cyan, colored));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
@@ -380,7 +445,7 @@ pub fn content_trim_colored(content: &str) -> String {
|
||||
}
|
||||
|
||||
// Regular content - colorize **bold** in magenta
|
||||
result.push_str(&colorize_line(line));
|
||||
result.push_str(&colorize_bold(line, colored));
|
||||
result.push('\n');
|
||||
}
|
||||
|
||||
@@ -401,7 +466,7 @@ pub fn colorize_ordered(line: &str) -> String {
|
||||
// still scanning digits
|
||||
} else if *c == '.' && i + 1 < chars.len() && chars[i + 1] == ' ' {
|
||||
let number = &line[..i + 1];
|
||||
result.push_str(&color_text(number, "cyan"));
|
||||
result.push_str(&color_text(number, Color::Cyan));
|
||||
result.push_str(&line[i + 1..]);
|
||||
return result;
|
||||
} else {
|
||||
@@ -450,7 +515,7 @@ fn metadata_value_cell(name: &str, value: &str, colored: bool) -> String {
|
||||
}
|
||||
|
||||
if is_unknown_value(value) {
|
||||
return paint(value, "grey", colored);
|
||||
return paint(value, Color::Grey, colored);
|
||||
}
|
||||
|
||||
value.to_string()
|
||||
@@ -486,7 +551,7 @@ fn render_metadata_table(lines: &[&str], colored: bool) -> String {
|
||||
for row in &rows {
|
||||
match row {
|
||||
MetadataRow::Field { name, value } => {
|
||||
result.push_str(&paint(name, "red", colored));
|
||||
result.push_str(&paint(name, Color::Red, colored));
|
||||
result.push_str(&" ".repeat(field_width - name.chars().count()));
|
||||
result.push_str(METADATA_GUTTER);
|
||||
result.push_str(&metadata_value_cell(name, value, colored));
|
||||
@@ -533,7 +598,7 @@ fn colorize_bold(line: &str, enabled: bool) -> String {
|
||||
match (i + 2..chars.len()).find(|&at| is_delimiter(&chars, at)) {
|
||||
Some(close) => {
|
||||
let bold: String = chars[i + 2..close].iter().collect();
|
||||
result.push_str(&color_text(&bold, "magenta"));
|
||||
result.push_str(&color_text(&bold, Color::Magenta));
|
||||
i = close + 2;
|
||||
}
|
||||
// Unterminated: the rest is literal. The old scan walked off the end
|
||||
@@ -929,10 +994,10 @@ pub fn numbered_criteria(criteria: &[Criterion], shown: &[usize]) -> String {
|
||||
.map(|(offset, criterion)| {
|
||||
format!(
|
||||
" {} {} {}",
|
||||
paint(&format!("{}.", offset + 1), "cyan", colored),
|
||||
paint(&format!("{}.", offset + 1), Color::Cyan, colored),
|
||||
paint(
|
||||
if criterion.checked { "[x]" } else { "[ ]" },
|
||||
"grey",
|
||||
Color::Grey,
|
||||
colored
|
||||
),
|
||||
criterion.text
|
||||
@@ -1083,6 +1148,9 @@ pub struct TicketItem {
|
||||
pub id: String,
|
||||
pub created: String,
|
||||
pub priority: Priority,
|
||||
/// The file this came from. The listing ignores it; the TUI opens it for the
|
||||
/// detail view rather than resolving the ticket a second time.
|
||||
pub path: std::path::PathBuf,
|
||||
}
|
||||
|
||||
/// Grey for a value that is not set, per the colour guideline.
|
||||
@@ -1091,7 +1159,7 @@ pub struct TicketItem {
|
||||
/// place that ignored the rule.
|
||||
fn dim_if_unset(value: &str, colored: bool) -> String {
|
||||
if is_unknown_value(value) {
|
||||
paint(value, "grey", colored)
|
||||
paint(value, Color::Grey, colored)
|
||||
} else {
|
||||
value.to_string()
|
||||
}
|
||||
@@ -1112,17 +1180,17 @@ fn dim_if_unset(value: &str, colored: bool) -> String {
|
||||
/// The number counts up while the mark empties out, because 1 is the most urgent.
|
||||
/// That is the convention every tracker uses and what the p1 tags this replaced
|
||||
/// already meant.
|
||||
pub fn priority_mark(priority: Priority) -> (&'static str, &'static str) {
|
||||
pub fn priority_mark(priority: Priority) -> (&'static str, Color) {
|
||||
match priority {
|
||||
Priority::Level(1) => ("\u{25cf}\u{25cf}", "brightred"),
|
||||
Priority::Level(2) => ("\u{25cf}\u{25d0}", "red"),
|
||||
Priority::Level(3) => ("\u{25cf}\u{25cb}", "orange"),
|
||||
Priority::Level(4) => ("\u{25d0}\u{25cb}", "cyan"),
|
||||
Priority::Level(5) => ("\u{25cb}\u{25cb}", "grey"),
|
||||
Priority::Level(1) => ("\u{25cf}\u{25cf}", Color::BrightRed),
|
||||
Priority::Level(2) => ("\u{25cf}\u{25d0}", Color::Red),
|
||||
Priority::Level(3) => ("\u{25cf}\u{25cb}", Color::Orange),
|
||||
Priority::Level(4) => ("\u{25d0}\u{25cb}", Color::Cyan),
|
||||
Priority::Level(5) => ("\u{25cb}\u{25cb}", Color::Grey),
|
||||
// Unreachable while Level is only built by parse_priority, which checks
|
||||
// the range, but a level added later should not silently render blank.
|
||||
Priority::Level(_) | Priority::Invalid => ("??", "brightred"),
|
||||
Priority::Unset => ("\u{b7}\u{b7}", "grey"),
|
||||
Priority::Level(_) | Priority::Invalid => ("??", Color::BrightRed),
|
||||
Priority::Unset => ("\u{b7}\u{b7}", Color::Grey),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1149,7 +1217,7 @@ pub fn display_ticket_items(items: &[TicketItem]) {
|
||||
let colored = should_use_colors();
|
||||
|
||||
for item in items {
|
||||
let id = paint(&item.id, "red", colored);
|
||||
let id = paint(&item.id, Color::Red, colored);
|
||||
let owner = dim_if_unset(&item.owner, colored);
|
||||
let due = dim_if_unset(&item.due, colored);
|
||||
let priority = show_priority(item.priority, colored);
|
||||
@@ -1160,7 +1228,7 @@ pub fn display_ticket_items(items: &[TicketItem]) {
|
||||
priority, id, item.title, owner, due
|
||||
);
|
||||
} else {
|
||||
let created = paint(&item.created, "cyan", colored);
|
||||
let created = paint(&item.created, Color::Cyan, colored);
|
||||
println!(
|
||||
" {} {} ({}) {} | Owner: {} | Due: {}",
|
||||
priority, created, id, item.title, owner, due
|
||||
@@ -1193,6 +1261,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
|
||||
id: short_id(&filename).to_string(),
|
||||
created: format_created_at(&created_at),
|
||||
priority: parse_priority(&content),
|
||||
path: e.path(),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -1247,7 +1316,7 @@ mod tests {
|
||||
for unset in ["_Not set_", "_None_"] {
|
||||
assert!(is_unknown_value(unset), "{unset} should count as unset");
|
||||
assert_eq!(dim_if_unset(unset, false), unset);
|
||||
assert_eq!(dim_if_unset(unset, true), paint(unset, "grey", true));
|
||||
assert_eq!(dim_if_unset(unset, true), paint(unset, Color::Grey, true));
|
||||
}
|
||||
|
||||
for set in ["alice", "2026-12-31", "bug,frontend"] {
|
||||
@@ -1690,15 +1759,27 @@ mod tests {
|
||||
#[test]
|
||||
fn the_ramp_avoids_green() {
|
||||
for level in PRIORITY_RANGE {
|
||||
assert_ne!(priority_mark(Priority::Level(level)).1, "green");
|
||||
assert_ne!(priority_mark(Priority::Level(level)).1, Color::Green);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_colour_the_code_asks_for_exists() {
|
||||
for colour in ["red", "cyan", "orange", "green", "grey", "magenta", "brightred"] {
|
||||
assert!(!get_color(colour).is_empty(), "{colour} is not defined");
|
||||
fn every_colour_has_an_escape_and_a_ratatui_equivalent() {
|
||||
// The old version of this test guarded against a name with no entry, which the
|
||||
// enum now makes a compile error. What is left worth asserting is that no
|
||||
// variant renders as nothing, and that the two renderers agree on the set.
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
|
||||
for colour in Color::ALL {
|
||||
assert!(!colour.ansi().is_empty(), "{colour:?} has no escape");
|
||||
assert!(
|
||||
colour.ansi().starts_with("\x1b["),
|
||||
"{colour:?} is not an SGR sequence"
|
||||
);
|
||||
assert!(seen.insert(ratatui::style::Color::from(colour)), "{colour:?} shares its ratatui colour");
|
||||
}
|
||||
|
||||
assert_eq!(seen.len(), Color::ALL.len());
|
||||
}
|
||||
|
||||
/// Pinned deliberately. Both SGR spellings of grey failed on a real palette,
|
||||
@@ -1707,7 +1788,7 @@ mod tests {
|
||||
/// so worklane's grey is the one frig and pantop already render.
|
||||
#[test]
|
||||
fn grey_matches_the_indexed_colour_frig_uses() {
|
||||
assert_eq!(get_color("grey"), "\x1b[38;5;8m");
|
||||
assert_eq!(Color::Grey.ansi(), "\x1b[38;5;8m");
|
||||
}
|
||||
|
||||
/// With no colour to carry the emphasis, the markers are the emphasis.
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
fn setup_worklane(temp: &TempDir) {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
/// Same message every other command gives. Checked before the terminal is, so the
|
||||
/// missing board is what gets reported rather than the missing tty.
|
||||
#[test]
|
||||
fn the_tui_outside_a_worklane_directory_gives_the_usual_message() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
for args in [vec!["tui"], vec![]] {
|
||||
let out = run(&temp, &args);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
||||
assert!(
|
||||
stderr.contains("No .worklane directory found"),
|
||||
"{args:?}: {stderr:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Raw mode on a pipe fails with a bare "No such device or address", which says nothing
|
||||
/// about the mistake. A bare `worklane` is how the board opens, so a script that lands
|
||||
/// here by accident has to be pointed at a subcommand.
|
||||
#[test]
|
||||
fn the_tui_without_a_terminal_says_so_and_names_an_alternative() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
for args in [vec!["tui"], vec![]] {
|
||||
let out = run(&temp, &args);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{args:?}: {stderr:?}");
|
||||
assert!(stderr.contains("worklane ls"), "{args:?}: {stderr:?}");
|
||||
assert!(
|
||||
!stderr.contains("os error"),
|
||||
"the raw mode error leaked: {stderr:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The subcommands must keep working now that the subcommand is optional.
|
||||
#[test]
|
||||
fn an_unknown_subcommand_is_still_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
assert_eq!(run(&temp, &["nonsense"]).status.code(), Some(2));
|
||||
assert_eq!(run(&temp, &["--bogus"]).status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// `tui` has to appear in the help, or nothing points at it.
|
||||
#[test]
|
||||
fn the_help_lists_the_tui_command() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&temp, &["--help"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert!(out.status.success());
|
||||
assert!(stdout.contains("tui"), "{stdout:?}");
|
||||
}
|
||||
Reference in New Issue
Block a user