Compare commits

..
6 Commits
Author SHA1 Message Date
Ansho ReiandClaude Opus 5 7240fc263b Record the overlay title decisions, and bump to 0.8.3
The bump for 0721739, which landed in the commit before this one. The board
section of AGENTS.md gains the two facts the next change to the modal needs:
the name travels beside the text in `Detail` rather than inside it, since
anything in the paragraph scrolls away and `content_trim` drops the heading on
purpose; and `detail_title` cuts the string itself because ratatui truncates a
block title at whatever cell it reaches and would take the id with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:42:53 +02:00
Ansho ReiandClaude Opus 5 580e3cf7f0 (0721739) Show the ticket id and title on the detail overlay's border
The modal named nothing. It showed a description, criteria and a metadata table
belonging to a ticket whose title is nowhere in the text, because content_trim
drops the `# ` heading on purpose: `cmd_show` prints it. The card behind the
overlay carries it, but the overlay covers most of the board, and the seven
characters of id in the metadata table were the only thing identifying what was
open.

The id and the name now sit on the block title, `(1111111) · First one`. The id
goes first because that is how every other view addresses a ticket, and both sit
on the border rather than at the head of the paragraph, so reading to the end of
a long ticket cannot carry them off the screen.

The string is cut here rather than left to the renderer, which truncates an
overlong block title at whatever cell it reaches and would take the id with it.
Cut against the inner width, the id survives whole and the name ends in an
ellipsis where it was trimmed.

`Board::detail` is now a `Detail` carrying the title, the id and the text, since
the title has to travel beside the body rather than inside it.

Written in an opencode session, lost from the working tree to a `git checkout
src/tui.rs` that Claude ran to drop a scratch test, and recovered from the
opencode snapshot store. The diff is unchanged from what was written, bar one
rebase conflict where both sides had added a test helper in the same place.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:41:26 +02:00
Ansho ReiandClaude Opus 5 2298d3373a (8528c50) Hide the done column in the tui until d asks for it, and bump to 0.8.2
Done only grows. It already holds more tickets than the other three columns
together, so a quarter of the width was going to the column least often read
while the ones being worked got squeezed for it.

Not a new opinion: `ls` already counts done in its summary and leaves it out of
the listing below. The board now does the same, and the footer carries the
count while the column is hidden, which is the board's version of that summary
line. It reads `d show done (17)` while hidden and `d hide done` while shown,
so the count only appears where a column heading is not already carrying it.
The modal footer names the key too, since it works with a ticket open.

Hiding is a change to what is drawn, never to what is read. `reload` still
scans the done directory and `digest` still watches it, so the count is right
and revealing the column needs no rescan.

`visible()` returns a prefix of the columns rather than a filter, which is what
keeps `column` and `offsets` valid as indices into either. It is derived from
where DONE actually sits rather than assuming the last slot, and a test pins
done as last: a status inserted after it would otherwise hide two columns in
silence. DONE is now a constant, since `ls` and the board are two readers of
the same rule.

Hiding the column under the selection moves the selection to the last drawn
column and closes an open detail view. Refreshing the modal onto whichever
ticket the selection landed on was the alternative, and it swaps what someone
is reading without saying so, which is how a person acts on the wrong ticket.
Showing done again is a no-op for the selection, since a column is appended
rather than inserted.

Three existing tests asserted a column heading with `screen.contains("done
(0)")` over the whole render, and the new footer holds that string whether the
column is drawn or not, so all three passed for the wrong reason the moment
done was hidden. They now assert against the top border row through a
`headings()` helper, with `footer()` beside it.

The choice is not remembered between runs: worklane has no config file, and one
flag is not a reason to start one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 16:30:06 +02:00
Ansho ReiandClaude Opus 5 8013c2b74d (d8e78cd) Clear the clippy warnings, and bump to 0.8.1
`cargo clippy --all-targets` was reporting 96 warnings, 14 of them in the
binary. It is now clean from a cold cache, and the 211 tests still pass.

`clippy --fix` took the mechanical ones: needless borrows, `map_or` that is
`is_some_and`, `push_str` of a single character, manual `split_once`, and
`&PathBuf` parameters in the test fixtures. It also moved the `handlers.rs`
test module to the end of the file, which is what `items_after_test_module`
was pointing at.

Three by hand. `cmd_add` took nine parameters threaded from `main`, and now
takes `AddArgs`, which is how `set`, `append` and `check` already pass theirs;
the handler destructures it so the body reads as before, and `add --help` is
unchanged. The collapsed `if` in `content_trim` needed reindenting, since
`--fix` left its body at the old depth. And the two `split_once` rewrites read
as `.split_once(..).map(|(_, value)| value)` rather than clippy's `.map(|x|
x.1)`.

The two eight-argument `create_ticket` test fixtures keep an
`allow(too_many_arguments)` carrying the reason: the lint is right that
twenty-five positional call sites read as a wall of strings, but replacing them
with a named-field struct is a refactor and not a warning sweep. a34a316 tracks
it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 15:37:11 +02:00
Ansho ReiandClaude Opus 5 6178d7bd3d (dd36e97) Add install-skill, shipping the agent skill in the binary, and bump to 0.8.0
worklane's agent instructions only existed for someone with the repo checked
out. Anyone who installed the binary with cargo install got no document at
all, because cargo install places binaries and nothing else.

The skill now lives at assets/SKILL.md and is embedded with include_str, so an
installed copy can never be a different version from the binary that describes
it. `worklane install-skill` writes it, `--print` sends it to stdout so a
modified copy can be diffed, and a copy that was edited is reported and left
alone unless --force: it may have been changed on purpose, and silently
discarding that is worse than stopping.

One path serves both agents, ~/.claude/skills/worklane/SKILL.md. That was
settled empirically rather than from documentation: opencode 1.15.10 loads
~/.claude/skills as an external skill source alongside its own
~/.config/opencode/skill, and with HOME pointed at a temp directory holding
only what install-skill wrote, `opencode debug skill` lists the document under
the name worklane. Writing opencode's own path as well would be two copies of
one document, free to drift, for no gain.

The document is new rather than the one under .opencode, which is the user's
and not this repo's to ship. The ticket-workflow prose moved out of AGENTS.md
into it, so how to use worklane has one writer, and AGENTS.md points there.

The mechanism is in install.rs rather than skill.rs, and install() takes its
root as an argument: install-tool is coming, it needs a different root and the
same compare-and-refuse logic, and passing the root is what lets the tests
install into a temp directory instead of the home of whoever runs the suite.

Three tests guard the document itself, which is the part that goes stale
quietly: the frontmatter has to parse, every `worklane <x>` it shows has to be
a real subcommand, and every subcommand outside NOT_FOR_AGENTS has to appear in
it, so a new command cannot ship invisible to an agent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 15:25:31 +02:00
Ansho Rei f740e42d1c Improvements to AGENTS.md file 2026-08-21 15:00:00 +02:00
20 changed files with 1281 additions and 274 deletions
+29 -9
View File
@@ -6,12 +6,15 @@
- `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
- `src/install.rs` - the embedded agent assets and the compare-and-refuse install
- `assets/SKILL.md` - the agent skill `install-skill` ships, embedded with `include_str!`
- `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
- Filenames: `<uuid_v4>_<slug>.md`
- The slug is the title through `slug()`: lowercased, alphanumerics plus `-` and `_` kept, spaces turned into dashes. `Ticket 06` lands as `<uuid>_ticket-06.md`. Derive fixture filenames through `slug()`, never by hand
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Status`
- Format: `**Field Name**: value`
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
@@ -20,20 +23,18 @@
## 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.
**How to use worklane is in `assets/SKILL.md`, not here.** That document is what
`worklane install-skill` ships, so it is the one place the flow, the move-as-you-work
rule and the argument traps are written down. Read it before working a ticket in this
repo. Do not restate any of it in this file: a second copy is a copy that goes stale,
and this file is for what someone changing worklane's own code needs.
## Testing
- Run: `cargo test`
- Tests use `assert_cmd` and `assert_fs` for CLI testing
- `setup_worklane()` creates temp `.worklane/` with all four status folders pre-created
- `create_ticket()` writes fully-formed markdown files directly (no `--` separator for positional args in test commands)
- **`cargo clippy --all-targets` is clean. Keep it clean**, and do not silence a lint that is pointing at something real. The only two `allow`s in the tree sit on the `create_ticket` fixtures in `cmd_mv.rs` and `cmd_show.rs`, each carrying the reason and what would replace it
## Coding Guidelines
@@ -43,6 +44,7 @@ front is the same two commands in a more useful order.
- Prefer explicit `match` over `unwrap_or_default()` for clarity
- Use `unwrap_or_else(|| expr)` for lazy defaults, `unwrap_or(val)` for eager defaults
- Use `anyhow!()` with context strings that include identifying info (e.g. UUID, title) not bare values
- A command whose arguments run past a handful takes a clap `Args` struct, not an inline variant with a matching parameter list: `AddArgs`, `SetArgs`, `AppendArgs`, `CheckArgs`. `add` was nine positional parameters threaded from `main` before it became `AddArgs`, and the handler destructures the struct so the body reads the same as before
### CLI Arguments
- The prose arguments carry `allow_hyphen_values`, via the `PROSE` constant in `command.rs`: `add --title`, `--description`, `--acceptance`, `--plan`, and the `comment` body. Ticket text quotes flag names constantly, and without it a criterion reading `--print is supported` is parsed as a flag and the whole ticket is refused with nothing written
@@ -90,10 +92,28 @@ front is the same two commands in a more useful order.
- **Columns scroll to keep the selected card in view.** `Board::offsets` holds one offset per column, parallel to `columns` and resized in step by `reload`, so a column you leave stays where it was. The keypress aligns the focused column via `follow_selection(screen)`, taking the screen size for the same reason `scroll_detail` does: the visible height belongs to the terminal, which only the caller measures between draws
- Card heights are measured on `card_lines`, never assumed, on both the keypress and the draw side (`card_height`, and the `starts` vec as the cards are built). An alignment that trusted a fixed card height would drift from the renderer the first time the card changed shape
- The draw aligns the focused column again on its own geometry, so a resize between keypress and frame cannot hide the selection, and caps every column against blank space past its last card. The stored value may go stale after a tick shrinks the column; that is fine, because what is drawn is corrected immediately and the next navigation writes the correction back
- Entering another column follows the selection rather than resetting to its top. The card index carries across columns, so a reset would open the column with the highlight below the fold whenever it was — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top
- Entering another column follows the selection rather than resetting to its top. The card index carries across columns, so a reset would open the column with the highlight below the fold whenever it was — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top. The index is shared and clamps permanently when a shorter column pulls it down, so a column you return to follows the selection to where it now sits rather than holding your old place
- **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 overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
- 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
- **Done is hidden until `d` asks for it.** Not a new opinion: `ls` already counts done in its summary and leaves it out of the listing. Done only grows, so a quarter of the width was going to the column least often read. The footer carries its count while it is hidden, which is the board's version of that summary line
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done directory and `digest` still watches it, so the footer count is right and revealing the column needs no rescan. Do not "optimise" that into a conditional scan
- `visible()` returns a prefix of `columns`, not a filter, which is what keeps `column` and `offsets` valid as indices into either. It is derived from where `DONE` actually sits rather than assuming the last slot, and `the_done_column_is_last` pins the assumption. A status inserted after done would otherwise hide two columns in silence
- Hiding the column under the selection moves the selection to the last drawn column and **closes an open detail view**. The alternative, refreshing the modal onto whichever ticket the selection landed on, swaps what someone is reading without saying so, which is how a person acts on the wrong ticket. Showing done again is a no-op for the selection, since a column is appended rather than inserted
- The choice is not remembered between runs. worklane has no config file and one flag is not a reason to start one; if it should persist, that is its own ticket
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not
### Shipping the Agent Assets
- The skill is embedded with `include_str!` from `assets/SKILL.md`, not copied by an install script. `cargo install` places binaries and nothing else, so an installed document that is not in the binary is a document that drifts from it
- **One install path serves both agents:** `~/.claude/skills/worklane/SKILL.md`. Claude Code reads it, and opencode loads that directory as an external skill source alongside its own `~/.config/opencode/skill/`. Verified against opencode 1.15.10, whose built-in `customize-opencode` skill documents the table and whose `opencode debug skill` lists what it found there. Do not add the second path: it is two copies of one document, free to drift, for no gain
- `Asset` carries the content, the path under its root and the word used in messages, so `install-tool` adds an entry and its own root rather than a second copy of the compare-and-refuse logic. That is why the module is `install.rs` and not `skill.rs`
- `install()` takes the root as an argument. That is what lets the tests install into a temp directory instead of the home of whoever runs the suite, and the integration test redirects `HOME` for the same reason
- **A modified copy is refused, not overwritten.** Someone may have edited it on purpose, and the message names `--print` so it can be diffed and `--force` so it can be replaced. A read error is not treated as absent either: the write reports the real reason
- Three tests guard the document rather than the mechanism, and they are the ones that earn their keep: the frontmatter has to parse (both agents silently ignore a document without it), every `worklane <x>` the skill shows has to be a real subcommand, and every subcommand outside `NOT_FOR_AGENTS` has to appear in the skill. The last one catches a new command that nothing tells an agent about
- `install-skill` looks for no board. The skill is what teaches an agent worklane, so needing a `.worklane` to install it would put it out of reach exactly when it is wanted
- The assets under `.opencode/` are the user's, not this repo's to ship. Do not embed or install them
### Color and Output
- Use `color_text()` for coloured output — it respects `should_use_colors()` (terminal detection), and `paint()` is the same with the decision passed in
Generated
+1 -1
View File
@@ -1494,7 +1494,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.7.2"
version = "0.8.3"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.7.2"
version = "0.8.3"
edition = "2024"
[dependencies]
+2 -1
View File
@@ -5,7 +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` or `worklane tui` | Opens the board: four status columns, redrawn when the tree changes. Read only. Opens on backlog, committed and reviewing; `d` shows or hides done, whose count stays in the footer either way. 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>` |
@@ -16,6 +16,7 @@ Worklane is a local Kanban flow for agentic software development.
| `worklane check <ticket> [criterion]` | Ticks one acceptance criterion, by number as shown by `show` or by a substring. Prompts with the numbered list if omitted, or errors with it when there is no terminal |
| `worklane uncheck <ticket> [criterion]` | Unticks one acceptance criterion, addressed the same way |
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
| `worklane install-skill` | Writes the embedded agent skill to `~/.claude/skills/worklane/SKILL.md`, which Claude Code and opencode both read. Leaves a modified copy alone unless `--force`; `--print` writes it to stdout instead |
## Exit codes
| Code | Meaning |
+143
View File
@@ -0,0 +1,143 @@
---
name: worklane
description: Manage tickets on a local worklane kanban board with the `worklane` CLI, backed by markdown files in a `.worklane/` directory. Use whenever you need to file, find, read, update, comment on or move a ticket, when asked what is on the board or what to pick up next, and when reporting work you are not going to do in the change at hand. Covers the four statuses, how a ticket is addressed, what belongs in each section, and the argument traps that silently swallow a flag.
---
# worklane
A kanban board as files. Every ticket is one markdown file in `.worklane/<status>/`,
named `<uuid>_<slug>.md`, and comments live in `.worklane/comments/<uuid>/`. The CLI is
the only thing that writes there: do not hand-edit or hand-place a file, because the
filename, the `Status` field and the directory have to agree and the commands are what
keep them agreeing.
Commands walk up from the working directory to find the nearest `.worklane`, so **run
`worklane` inside the repo the ticket belongs to**. Which directory you run it in is
what decides which board the ticket lands on.
`worklane` with no subcommand opens an interactive board and needs a terminal. It is for
a person, not for you: it takes over the screen and does not return until quit.
## The flow
`backlog` → `committed` → `reviewing` → `done`
**Move the ticket as you work it, not afterwards.** `worklane mv <id> --status committed`
before writing any code, and `--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. `-f` allows a backward or
skipping move, for correcting a mistake.
## Reading the board
```
worklane ls # every status, counts then tickets
worklane ls backlog # one status
worklane ls --priority 1 # only the most urgent
worklane show 1b78a24 # one ticket, body and comments
```
`ls` prints a seven-character id per ticket. That is what you address it by.
## Working a ticket
```
worklane mv 1b78a24 --status committed
worklane check 1b78a24 3 # tick acceptance criterion 3
worklane check 1b78a24 "the footer describes" # or a substring of it
worklane uncheck 1b78a24 3
worklane comment 1b78a24 "Found the cause: the offset was never passed to the widget."
worklane mv 1b78a24 --status reviewing
```
Criteria are numbered by `show`. With the criterion omitted, `check` prompts when there
is a terminal and otherwise fails with the numbered list, so **always pass the criterion
when you are not sitting at a prompt**.
## Filing a ticket
```
worklane add \
--title "The tui detail view cannot scroll" \
--description "Opening a ticket and pressing down moves to the next one instead." \
--description "" \
--description "Up and down are bound to select_card unconditionally, src/main.rs." \
--acceptance "PageUp and PageDown scroll the detail view" \
--acceptance "The footer describes the keys that exist" \
--plan "Add a scroll offset to Board and pass it to Paragraph::scroll" \
--plan "Clamp against the wrapped line count, not the raw line count" \
--priority 2 --tags bug,tui
```
`add` always lands in `backlog`. Nothing is created without `--title`.
- **`--description`** is the case for the ticket: the symptom, then what is actually
wrong, naming the files, functions and settings involved. Repeat the flag for more
lines; an empty `--description ""` between two values is a paragraph break.
- **`--acceptance`** takes one criterion per flag, each a statement that can be
checked off as true or false.
- **`--plan`** takes one step per flag, numbered for you.
- **`--priority`** runs 1 (most urgent) to 5 (least), and is left unset if omitted.
Editing afterwards, on a ticket in any status:
```
worklane set 1b78a24 --priority 1 # replace a field
worklane set 1b78a24 --title "A better title" # renames the file, keeps the uuid
worklane append 1b78a24 --acceptance "One more criterion"
worklane append 1b78a24 --description "What was learned since."
```
`set` replaces, `append` adds. Neither has `--owner` or `--status`: owner is its own
command's, and status is `mv`'s. A field set to the value it already holds is reported
unchanged and nothing is written.
`worklane init` creates `.worklane/` with the four status directories, for a repo that
has no board yet.
## Search the backlog before filing
Run `worklane ls` in the directory the ticket would land in and look for the same issue,
including tickets already committed, in review or done. Search by the symptom and by the
name of the function or setting involved, not only by your own phrasing of the title: an
existing ticket will have been written from a different angle.
- Already there and still open: add what you learned as a comment, not a second ticket.
- Already there and closed, but the issue is back: file a **new** ticket naming the old
id, and say it is a regression. There is no way to reopen one, and moving a done
ticket back would destroy the record of the original fix.
- Related but not the same: file it and reference the neighbour by id.
## Addressing a ticket
Every command that takes a ticket accepts, in this order of precedence:
1. a UUID prefix, from four characters up
2. a substring of the title
3. a substring of the filename
The first tier that matches anything wins outright; the later tiers are not consulted.
This matters because ticket titles quote other tickets' ids, and a flat search reported
an exact id as ambiguous against whichever title mentioned it. An ambiguous match prints
the candidates and exits 1 rather than guessing.
## Traps
- **Prose arguments accept a leading hyphen**: `--title`, `--description`,
`--acceptance`, `--plan` and the `comment` body. A criterion reading
`--print is supported` is stored, not parsed as a flag. The cost is that a genuinely
mistyped flag there lands as content instead of failing, so read back what you wrote
with `worklane show`.
- `--due`, `--priority`, `--tags`, `--owner` and `--status` do *not* accept one, so a
mistyped flag on those is a usage error and nothing is written.
- A ticket argument that starts with a hyphen needs the flags first and a separator:
`worklane mv --status committed -- -leading-title`.
- A comment body of exactly `--` needs its own separator:
`worklane comment 1b78a24 -- --`.
- An empty value for a scalar is a usage error. Clearing a field back to unset is not
supported yet.
- Piping is safe: `worklane ls | head -3` exits on the closed pipe instead of panicking.
+53 -33
View File
@@ -70,39 +70,7 @@ pub enum Command {
Init,
/// Add a new ticket to the backlog
Add {
/// Ticket title
#[arg(short, long, allow_hyphen_values = PROSE)]
title: String,
/// Ticket description. Use multiple flags to create multiline descriptions.
#[arg(short, long, allow_hyphen_values = PROSE)]
description: Vec<String>,
/// Acceptance criteria. Accepts multiple flags, each will be interpreted as a single criterium
#[arg(short, long, allow_hyphen_values = PROSE)]
acceptance: Vec<String>,
/// Implementation plan. Accepts multiple flags, each will be interpreted as a single step
#[arg(short, long, allow_hyphen_values = PROSE)]
plan: Vec<String>,
/// Tags (comma-separated)
#[arg(short = 'g', long)]
tags: Vec<String>,
/// Due date (YYYY-MM-DD)
#[arg(long)]
due: Option<String>,
/// Owner
#[arg(short, long)]
owner: Option<String>,
/// Priority, 1 (most urgent) to 5 (least). Left unset if omitted.
#[arg(long, value_parser = priority_level)]
priority: Option<u8>,
},
Add(AddArgs),
/// List tickets, optionally filtered by status
#[command(after_help = PRIORITY_LEGEND.as_str())]
@@ -163,6 +131,58 @@ pub enum Command {
#[arg(short, long)]
owner: Option<String>,
},
/// Install the agent skill that teaches an agent to use worklane
InstallSkill {
/// Overwrite an existing copy that has been modified
#[arg(long)]
force: bool,
/// Write it to stdout instead of installing it
#[arg(long)]
print: bool,
},
}
/// `add` carries every field a new ticket can hold, so it is a struct rather than an
/// inline variant: nine parameters at the call site is what `too_many_arguments` is
/// for, and `set`, `append` and `check` already pass their arguments this way.
///
/// No `ArgGroup`: `--title` is required on its own, and everything else is optional
/// because a ticket with only a title is a valid thing to file.
#[derive(clap::Args)]
pub struct AddArgs {
/// Ticket title
#[arg(short, long, allow_hyphen_values = PROSE)]
pub title: String,
/// Ticket description. Use multiple flags to create multiline descriptions.
#[arg(short, long, allow_hyphen_values = PROSE)]
pub description: Vec<String>,
/// Acceptance criteria. Accepts multiple flags, each will be interpreted as a single criterium
#[arg(short, long, allow_hyphen_values = PROSE)]
pub acceptance: Vec<String>,
/// Implementation plan. Accepts multiple flags, each will be interpreted as a single step
#[arg(short, long, allow_hyphen_values = PROSE)]
pub plan: Vec<String>,
/// Tags (comma-separated)
#[arg(short = 'g', long)]
pub tags: Vec<String>,
/// Due date (YYYY-MM-DD)
#[arg(long)]
pub due: Option<String>,
/// Owner
#[arg(short, long)]
pub owner: Option<String>,
/// Priority, 1 (most urgent) to 5 (least). Left unset if omitted.
#[arg(long, value_parser = priority_level)]
pub priority: Option<u8>,
}
/// `set` replaces a field outright. Owner is deliberately absent: `chown` owns that
+85 -51
View File
@@ -4,7 +4,8 @@ use std::fs;
use std::io::{BufRead, IsTerminal, Write};
use std::path::Path;
use crate::command::{AppendArgs, CheckArgs, SetArgs};
use crate::command::{AddArgs, AppendArgs, CheckArgs, SetArgs};
use crate::install;
use crate::util::*;
pub fn cmd_init(start: &Path) -> Result<()> {
@@ -70,7 +71,7 @@ pub fn cmd_ls(
// Show all tickets except done grouped by status
for status in &statuses {
if *status == "done" {
if *status == DONE {
continue;
}
let status_path = worklane_dir.join(status);
@@ -104,17 +105,18 @@ fn filter_by_priority(items: Vec<TicketItem>, level: Option<u8>) -> Vec<TicketIt
}
}
pub fn cmd_add(
title: &str,
description: &[String],
acceptance: &[String],
plan: &[String],
tags: &[String],
due: &Option<String>,
owner: &Option<String>,
priority: Option<u8>,
start: &Path,
) -> Result<()> {
pub fn cmd_add(args: &AddArgs, start: &Path) -> Result<()> {
let AddArgs {
title,
description,
acceptance,
plan,
tags,
due,
owner,
priority,
} = args;
let owner = match owner {
Some(o) => Some(o.clone()),
None => get_git_user(),
@@ -221,7 +223,7 @@ pub fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String,
for entry in fs::read_dir(comments_dir)? {
let entry = entry?;
let path = entry.path();
if path.extension().map_or(false, |e| e == "md") {
if path.extension().is_some_and(|e| e == "md") {
let content = fs::read_to_string(&path)?;
let filename = path
.file_stem()
@@ -231,14 +233,16 @@ pub fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String,
let author = content
.lines()
.find(|l| l.starts_with("**Author**"))
.and_then(|l| l.splitn(2, "**Author**:").nth(1))
.and_then(|l| l.split_once("**Author**:"))
.map(|(_, value)| value)
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
let time = content
.lines()
.find(|l| l.starts_with("**Time**"))
.and_then(|l| l.splitn(2, "**Time**:").nth(1))
.and_then(|l| l.split_once("**Time**:"))
.map(|(_, value)| value)
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
@@ -371,7 +375,7 @@ fn find_ticket_file(dir: &Path, uuid: &str, title: &str) -> Result<String> {
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if !path.extension().map_or(false, |e| e == "md") {
if !path.extension().is_some_and(|e| e == "md") {
continue;
}
@@ -471,7 +475,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, Color::Orange)
color_text(target_status, Color::Orange)
);
return Ok(());
}
@@ -505,39 +509,6 @@ pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
/// The collision path cannot be provoked from the CLI, since two processes
/// will not share a microsecond, but it is the whole point of the guard.
#[test]
fn a_colliding_stem_takes_the_next_name_and_keeps_the_first() {
let dir = std::env::temp_dir().join(format!("worklane-test-{}", uuid::Uuid::new_v4()));
fs::create_dir_all(&dir).unwrap();
let first = write_new_comment(&dir, "20260820_143012_123456", "first").unwrap();
let second = write_new_comment(&dir, "20260820_143012_123456", "second").unwrap();
let third = write_new_comment(&dir, "20260820_143012_123456", "third").unwrap();
assert_eq!(first, "20260820_143012_123456.md");
assert_eq!(second, "20260820_143012_123456_01.md");
assert_eq!(third, "20260820_143012_123456_02.md");
// Nothing was truncated on the way through
assert_eq!(fs::read_to_string(dir.join(&first)).unwrap(), "first");
assert_eq!(fs::read_to_string(dir.join(&second)).unwrap(), "second");
assert_eq!(fs::read_to_string(dir.join(&third)).unwrap(), "third");
// read_comments sorts on the stem, so the names must sort in write order
let mut names = vec![second.clone(), third.clone(), first.clone()];
names.sort();
assert_eq!(names, vec![first, second, third]);
fs::remove_dir_all(&dir).unwrap();
}
}
pub fn cmd_comment(
ticket_id: &str,
body: &str,
@@ -868,3 +839,66 @@ pub fn cmd_check(args: &CheckArgs, checked: bool, start: &Path) -> Result<()> {
);
Ok(())
}
/// Install the agent skill, or print it so a modified copy can be diffed.
///
/// No board is looked for. The document is what teaches an agent worklane, so needing
/// a `.worklane` to install it would put it out of reach exactly when it is wanted.
pub fn cmd_install_skill(force: bool, print: bool) -> Result<()> {
if print {
print!("{}", install::SKILL.content);
return Ok(());
}
let root = install::skills_root()?;
match install::SKILL.install(&root, force)? {
install::Outcome::Written(path) => {
println!("Installed the worklane {} to: {}", install::SKILL.what, path.display());
println!("Claude Code and opencode pick it up on their next session");
}
install::Outcome::Unchanged(path) => {
println!("Already up to date: {}", path.display());
}
install::Outcome::Refused(path) => {
println!("Differs from the version in this binary: {}", path.display());
println!(
"Compare with `worklane install-skill --print`, or overwrite with --force"
);
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
/// The collision path cannot be provoked from the CLI, since two processes
/// will not share a microsecond, but it is the whole point of the guard.
#[test]
fn a_colliding_stem_takes_the_next_name_and_keeps_the_first() {
let dir = std::env::temp_dir().join(format!("worklane-test-{}", uuid::Uuid::new_v4()));
fs::create_dir_all(&dir).unwrap();
let first = write_new_comment(&dir, "20260820_143012_123456", "first").unwrap();
let second = write_new_comment(&dir, "20260820_143012_123456", "second").unwrap();
let third = write_new_comment(&dir, "20260820_143012_123456", "third").unwrap();
assert_eq!(first, "20260820_143012_123456.md");
assert_eq!(second, "20260820_143012_123456_01.md");
assert_eq!(third, "20260820_143012_123456_02.md");
// Nothing was truncated on the way through
assert_eq!(fs::read_to_string(dir.join(&first)).unwrap(), "first");
assert_eq!(fs::read_to_string(dir.join(&second)).unwrap(), "second");
assert_eq!(fs::read_to_string(dir.join(&third)).unwrap(), "third");
// read_comments sorts on the stem, so the names must sort in write order
let mut names = vec![second.clone(), third.clone(), first.clone()];
names.sort();
assert_eq!(names, vec![first, second, third]);
fs::remove_dir_all(&dir).unwrap();
}
}
+282
View File
@@ -0,0 +1,282 @@
//! Shipping the agent assets with the binary.
//!
//! The skill document lives at `assets/SKILL.md` in this repo and is embedded with
//! `include_str!` rather than copied by an install script, because `cargo install`
//! places binaries and nothing else. Embedding means the document can never be a
//! different version from the binary it describes, and there is no second file to
//! lose track of.
//!
//! The machinery is written once for both assets this repo will ship. The tool file
//! for opencode is executable code needing Bun, so it gets its own command and its
//! own root, but the compare-and-refuse logic is the same and lives here.
use std::io;
use std::path::{Path, PathBuf};
use anyhow::{Result, anyhow};
/// One thing the binary carries and can write into a user's agent configuration.
pub struct Asset {
/// What it is called in messages, e.g. `skill`.
pub what: &'static str,
/// Where it goes under its root, e.g. `worklane/SKILL.md`.
pub relative: &'static str,
pub content: &'static str,
}
/// The skill document, as of the commit this binary was built from.
pub const SKILL: Asset = Asset {
what: "skill",
relative: "worklane/SKILL.md",
content: include_str!("../assets/SKILL.md"),
};
/// Where a skill has to sit to be found, for both agents worklane is used from.
///
/// One path serves both. Claude Code reads `~/.claude/skills/<name>/SKILL.md`, and
/// opencode loads that same directory as an external skill source, alongside its own
/// `~/.config/opencode/skill/`. Checked against opencode 1.15.10, whose built-in
/// `customize-opencode` skill documents it and whose `opencode debug skill` lists the
/// documents found there. Writing both paths would be two copies of one document, free
/// to drift apart, for no gain.
pub fn skills_root() -> Result<PathBuf> {
let home = std::env::var_os("HOME").ok_or_else(|| {
anyhow!("cannot tell where your skills live because HOME is not set in the environment")
})?;
Ok(Path::new(&home).join(".claude/skills"))
}
#[derive(Debug, PartialEq, Eq)]
pub enum Outcome {
Written(PathBuf),
/// Already byte-identical, so writing it again would be a no-op.
Unchanged(PathBuf),
/// Present but different, and no `--force`. Refused rather than overwritten: it
/// may have been edited on purpose, and silently discarding that is worse than
/// stopping.
Refused(PathBuf),
}
impl Asset {
pub fn path(&self, root: &Path) -> PathBuf {
root.join(self.relative)
}
/// Write the asset under `root`, unless what is there is the same or was changed.
///
/// The root is passed in rather than looked up, so a test can install into a
/// temporary directory instead of the home of whoever runs the suite.
pub fn install(&self, root: &Path, force: bool) -> io::Result<Outcome> {
let path = self.path(root);
// A read error is not treated as "absent": the write below reports it, with
// the real reason, rather than this guessing that the file is missing.
match std::fs::read_to_string(&path) {
Ok(existing) if existing == self.content => return Ok(Outcome::Unchanged(path)),
Ok(_) if !force => return Ok(Outcome::Refused(path)),
_ => {}
}
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)?;
}
std::fs::write(&path, self.content)?;
Ok(Outcome::Written(path))
}
}
/// The `name:` and `description:` from the YAML frontmatter.
///
/// Used by the tests that guard the shipping mechanism, which is the only thing that
/// needs it: both agents decide whether to load a document from these two fields, and
/// a document missing them is ignored in silence.
#[cfg_attr(not(test), allow(dead_code))]
fn frontmatter_field(text: &str, key: &str) -> Option<String> {
let body = text.strip_prefix("---\n")?;
let end = body.find("\n---")?;
body[..end]
.lines()
.find_map(|line| line.strip_prefix(&format!("{key}:")))
.map(|value| value.trim().to_string())
}
#[cfg(test)]
mod tests {
use super::*;
fn root() -> tempfile::TempDir {
tempfile::tempdir().unwrap()
}
#[test]
fn the_skill_installs_into_a_directory_that_does_not_exist_yet() {
let root = root();
let path = SKILL.path(root.path());
assert_eq!(
SKILL.install(root.path(), false).unwrap(),
Outcome::Written(path.clone())
);
assert_eq!(std::fs::read_to_string(&path).unwrap(), SKILL.content);
}
/// Installing twice is a no-op rather than a rewrite, so the mtime of an
/// up-to-date copy does not move.
#[test]
fn a_second_install_reports_the_copy_unchanged() {
let root = root();
SKILL.install(root.path(), false).unwrap();
assert_eq!(
SKILL.install(root.path(), false).unwrap(),
Outcome::Unchanged(SKILL.path(root.path()))
);
}
/// The case worth being careful about: an edited copy is someone's work.
#[test]
fn a_modified_copy_is_refused_and_left_alone() {
let root = root();
let path = SKILL.path(root.path());
SKILL.install(root.path(), false).unwrap();
std::fs::write(&path, "hand written\n").unwrap();
assert_eq!(
SKILL.install(root.path(), false).unwrap(),
Outcome::Refused(path.clone())
);
assert_eq!(std::fs::read_to_string(&path).unwrap(), "hand written\n");
assert_eq!(
SKILL.install(root.path(), true).unwrap(),
Outcome::Written(path.clone())
);
assert_eq!(std::fs::read_to_string(&path).unwrap(), SKILL.content);
}
#[test]
fn the_skill_lands_where_both_agents_look_for_it() {
let root = skills_root().unwrap();
assert!(root.ends_with(".claude/skills"), "{}", root.display());
assert!(
SKILL.path(&root).ends_with(".claude/skills/worklane/SKILL.md"),
"{}",
SKILL.path(&root).display()
);
}
#[test]
fn the_embedded_skill_has_usable_frontmatter() {
// Guards the whole shipping mechanism: without frontmatter, or under a name
// that does not match its directory, both agents ignore the document and
// nothing else would notice.
assert_eq!(frontmatter_field(SKILL.content, "name").as_deref(), Some("worklane"));
let description =
frontmatter_field(SKILL.content, "description").expect("a description to trigger on");
assert!(
description.len() > 80,
"the description is what decides whether the skill loads at all"
);
}
/// Every code span and fenced-block line, which is where commands live.
///
/// Prose has to be excluded: the document opens by calling worklane a kanban
/// board, and treating that sentence as a command makes the check useless.
fn code_snippets(text: &str) -> Vec<String> {
let mut snippets = Vec::new();
let mut fenced = false;
for line in text.lines() {
if line.trim_start().starts_with("```") {
fenced = !fenced;
continue;
}
if fenced {
snippets.push(line.to_string());
continue;
}
// Inline spans: the odd-numbered pieces between backticks.
for (index, piece) in line.split('`').enumerate() {
if index % 2 == 1 {
snippets.push(piece.to_string());
}
}
}
snippets
}
#[test]
fn the_embedded_skill_only_names_commands_that_exist() {
// Taken from clap rather than written out here. A hand-maintained list is the
// very drift this test exists to catch.
use clap::CommandFactory;
let mut known: Vec<String> = crate::Cli::command()
.get_subcommands()
.map(|c| c.get_name().to_string())
.collect();
known.push("--help".to_string());
known.push("--version".to_string());
let mut checked = 0;
for snippet in code_snippets(SKILL.content) {
let mut words = snippet.split_whitespace();
// Only a snippet that *starts* with worklane is a command being shown.
if words.next() != Some("worklane") {
continue;
}
let Some(candidate) = words.next() else { continue };
// A flag before the subcommand, as in the `mv -- -leading-title` example.
if candidate.starts_with("--") && !known.iter().any(|k| k == candidate) {
continue;
}
checked += 1;
assert!(
known.iter().any(|k| k == candidate),
"the skill shows `worklane {candidate}`, which is not a subcommand"
);
}
assert!(checked > 8, "expected the skill to show commands, checked only {checked}");
}
/// Subcommands the skill has no business teaching: the board is interactive and
/// belongs to a person, `install-skill` is how the document arrived, and `help`
/// is clap's own.
const NOT_FOR_AGENTS: [&str; 3] = ["tui", "install-skill", "help"];
/// The converse, and the one that goes stale on its own: a *new* subcommand absent
/// from the skill is invisible to an agent, and nothing else would notice.
#[test]
fn every_agent_facing_subcommand_is_documented() {
use clap::CommandFactory;
for command in crate::Cli::command().get_subcommands() {
let name = command.get_name();
if NOT_FOR_AGENTS.contains(&name) {
continue;
}
assert!(
SKILL.content.contains(&format!("worklane {name}")),
"the skill never mentions `worklane {name}`, so an agent will not know it exists"
);
}
}
/// The facts an agent cannot infer from the help output and would get wrong.
#[test]
fn the_embedded_skill_documents_what_the_help_does_not() {
for required in [
"committed",
"as you work it",
"UUID prefix",
"leading hyphen",
"Search the backlog before filing",
] {
assert!(
SKILL.content.contains(required),
"the skill no longer mentions {required:?}"
);
}
}
}
+7 -20
View File
@@ -3,6 +3,7 @@ use clap::Parser;
mod command;
mod handlers;
mod install;
mod tui;
mod util;
@@ -40,26 +41,7 @@ fn main() -> Result<()> {
// 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,
plan,
tags,
due,
owner,
priority,
}) => cmd_add(
&title,
&description,
&acceptance,
&plan,
&tags,
&due,
&owner,
priority,
&start,
),
Some(Command::Add(args)) => cmd_add(&args, &start),
Some(Command::Ls { status, priority }) => {
let worklane_dir = find_worklane_dir(&start)?;
cmd_ls(&status, priority, &worklane_dir)
@@ -82,6 +64,9 @@ fn main() -> Result<()> {
body,
owner,
}) => cmd_comment(&ticket, &body, &owner, &start),
// No board is looked for: the point of the skill is to teach an agent worklane
// before there is a `.worklane` anywhere.
Some(Command::InstallSkill { force, print }) => cmd_install_skill(force, print),
}
}
@@ -176,6 +161,8 @@ fn run_tui(start: &std::path::Path) -> Result<()> {
KeyCode::Down | KeyCode::Char('j') => board.select_card(1, screen),
KeyCode::PageUp => board.scroll_detail(-1, screen),
KeyCode::PageDown => board.scroll_detail(1, screen),
// Free of the other bindings, and the footer names it in both states.
KeyCode::Char('d') => board.toggle_done(screen),
_ => {}
}
}
+447 -42
View File
@@ -30,6 +30,19 @@ pub struct Column {
pub tickets: Vec<TicketItem>,
}
/// What the detail view holds while it is open: the ticket it belongs to, then its
/// body and comments as one plain text.
///
/// The title travels beside the text rather than inside it, because it does not
/// scroll: it names the overlay from the border, where no amount of reading can
/// carry it off the screen.
#[derive(Debug)]
pub struct Detail {
pub title: String,
pub id: String,
pub text: String,
}
/// What is on screen.
pub struct Board {
pub columns: Vec<Column>,
@@ -38,10 +51,13 @@ pub struct Board {
/// First visible line of each column, counted in card lines. Parallel to
/// `columns`, so a tick that reshapes the board resizes it in step.
pub offsets: Vec<u16>,
/// The body and comments of the selected ticket, when the detail view is open.
pub detail: Option<String>,
/// The open detail view, when one is open.
pub detail: Option<Detail>,
/// First visible line of the detail view, counted in wrapped lines.
pub offset: u16,
/// Whether the done column is drawn. Off at startup, and not remembered between
/// runs: worklane has no config file, and one flag is not a reason to start one.
pub show_done: bool,
pub should_quit: bool,
worklane_dir: PathBuf,
digest: u64,
@@ -56,6 +72,7 @@ impl Board {
offsets: Vec::new(),
detail: None,
offset: 0,
show_done: false,
should_quit: false,
worklane_dir: worklane_dir.to_path_buf(),
digest: 0,
@@ -109,15 +126,63 @@ impl Board {
Ok(())
}
/// The columns that are drawn: all of them, or everything up to done.
///
/// A prefix rather than a filter, which is what keeps `column` and `offsets` usable
/// as indices into either. Taken from where done actually is instead of assuming the
/// last slot, with a test pinning done as last so the two cannot drift apart.
pub fn visible(&self) -> &[Column] {
&self.columns[..self.visible_count()]
}
fn visible_count(&self) -> usize {
if self.show_done {
return self.columns.len();
}
match self.columns.iter().position(|column| column.status == DONE) {
Some(index) => index,
None => self.columns.len(),
}
}
/// Show or hide the done column.
///
/// `ls` already holds this opinion: it counts done in its summary and leaves it out
/// of the listing. Done only grows, so a quarter of the width goes to the column
/// least often read while the three being worked get squeezed for it.
///
/// Hiding is a change to what is drawn, never to what is read. The directory stays
/// scanned and stays in the digest, so the count in the footer is right and revealing
/// the column needs no rescan.
pub fn toggle_done(&mut self, screen: Size) {
self.show_done = !self.show_done;
// Showing done again appends a column, so nothing below is reached and the
// selection stays exactly where it was.
if self.column < self.visible_count() {
return;
}
// Hiding the column the selection is in moves it to the last one still drawn.
// An open detail closes with it: it is showing a ticket that is no longer on the
// board, and quietly swapping it for a different ticket is worse than closing.
self.clamp();
self.detail = None;
self.offset = 0;
self.follow_selection(screen);
}
/// Keep the selection on a card that exists, after the board changes under it.
fn clamp(&mut self) {
if self.columns.is_empty() {
let visible = self.visible_count();
if visible == 0 {
self.column = 0;
self.card = 0;
return;
}
self.column = self.column.min(self.columns.len() - 1);
self.column = self.column.min(visible - 1);
let count = self.columns[self.column].tickets.len();
self.card = match count {
0 => 0,
@@ -133,11 +198,12 @@ impl Board {
/// Move between columns, keeping the card index where it can land.
pub fn select_column(&mut self, delta: isize, screen: Size) {
if self.columns.is_empty() {
if self.visible_count() == 0 {
return;
}
let last = self.columns.len() as isize - 1;
// Bounded by what is drawn, so the selection cannot walk into a hidden column.
let last = self.visible_count() as isize - 1;
let next = (self.column as isize + delta).clamp(0, last);
self.column = next as usize;
self.clamp();
@@ -221,7 +287,7 @@ impl Board {
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;
let last = last_offset(&detail.text, text) as isize;
self.offset = (self.offset as isize + pages.saturating_mul(step)).clamp(0, last) as u16;
}
@@ -236,11 +302,12 @@ impl Board {
}
}
/// The whole ticket as plain text: the body as `show` renders it, then the comments.
/// The ticket as the detail view holds it: its name and short id, then the body as
/// `show` renders it and 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 {
fn detail_of(ticket: &TicketItem) -> Detail {
let content = std::fs::read_to_string(&ticket.path).unwrap_or_default();
let mut out = content_trim(&content, false);
@@ -254,7 +321,11 @@ fn detail_of(ticket: &TicketItem) -> String {
out.push('\n');
out.push_str(&format_comments_with(&comments, false));
out
Detail {
title: ticket.title.clone(),
id: ticket.id.clone(),
text: out,
}
}
/// A fingerprint of every ticket and comment file: name, length and modified time.
@@ -326,10 +397,12 @@ pub fn draw(frame: &mut Frame, board: &Board) {
}
fn draw_columns(frame: &mut Frame, board: &Board, area: Rect) {
let widths: Vec<Constraint> = board
.columns
// Only the drawn columns are measured, so hiding done gives its width back to the
// three that are left rather than leaving a gap where it was.
let columns = board.visible();
let widths: Vec<Constraint> = columns
.iter()
.map(|_| Constraint::Ratio(1, board.columns.len().max(1) as u32))
.map(|_| Constraint::Ratio(1, columns.len().max(1) as u32))
.collect();
let areas = Layout::default()
@@ -337,7 +410,7 @@ fn draw_columns(frame: &mut Frame, board: &Board, area: Rect) {
.constraints(widths)
.split(area);
for (index, column) in board.columns.iter().enumerate() {
for (index, column) in columns.iter().enumerate() {
let focused = index == board.column;
let title = format!(" {} ({}) ", column.status, column.tickets.len());
@@ -464,9 +537,16 @@ fn card_lines(ticket: &TicketItem, selected: bool) -> Vec<Line<'static>> {
}
fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) {
// While done is hidden its count goes here, which is the board's version of the
// summary line `ls` prints above a listing that leaves done out.
let done = match board.show_done {
true => "d hide done".to_string(),
false => format!("d show done ({})", done_count(board)),
};
let keys = match board.detail {
Some(_) => " ←→↑↓ select pgup/pgdn scroll enter close q quit ",
None => " ←→ column ↑↓ card enter detail q quit ",
Some(_) => format!(" ←→↑↓ select pgup/pgdn scroll enter close {done} q quit "),
None => format!(" ←→ column ↑↓ card enter detail {done} q quit "),
};
frame.render_widget(
@@ -475,6 +555,15 @@ fn draw_footer(frame: &mut Frame, board: &Board, area: Rect) {
);
}
/// How many tickets are in done, drawn or not.
fn done_count(board: &Board) -> usize {
board
.columns
.iter()
.find(|column| column.status == DONE)
.map_or(0, |column| column.tickets.len())
}
/// Where the detail overlay sits in the frame.
///
/// Inset, so the board stays visible around the edges and the overlay reads as one.
@@ -510,24 +599,24 @@ fn last_offset(detail: &str, text: Rect) -> u16 {
.saturating_sub(text.height)
}
fn draw_detail(frame: &mut Frame, detail: &str, offset: u16, area: Rect) {
fn draw_detail(frame: &mut Frame, detail: &Detail, 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 offset = offset.min(last_offset(&detail.text, detail_text_area(area)));
let block = Block::default()
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::Cyan.into()))
.title(Span::styled(
" ticket ",
detail_title(detail, overlay.width),
Style::default().fg(Color::Orange.into()),
));
frame.render_widget(Clear, overlay);
frame.render_widget(
Paragraph::new(detail.to_string())
Paragraph::new(detail.text.to_string())
.block(block)
.wrap(Wrap { trim: false })
.scroll((offset, 0)),
@@ -535,6 +624,35 @@ fn draw_detail(frame: &mut Frame, detail: &str, offset: u16, area: Rect) {
);
}
/// The overlay's title: the short id and the name of the ticket it has open.
///
/// The id goes first because that is how every other view addresses a ticket, and the
/// name after it because that is what the id is shorthand for. Both sit on the border
/// rather than at the head of the paragraph, so reading to the end of a long ticket
/// cannot carry them off the screen.
///
/// The string is cut here rather than left to the renderer, which truncates an
/// overlong title at whatever cell it reaches and would take the id with it. Cut
/// against the inner width — a border column on either side is not the title's to
/// write on — the id survives whole and the name ends in an ellipsis where it was
/// trimmed. On an overlay too narrow for even the id, what fits is what shows.
fn detail_title(detail: &Detail, overlay_width: u16) -> String {
let room = overlay_width.saturating_sub(2) as usize;
let full = format!(" ({}) · {} ", detail.id, detail.title);
if full.chars().count() <= room {
return full;
}
let prefix = format!(" ({}) · ", detail.id);
match room.checked_sub(prefix.chars().count() + 1) {
Some(keep) if keep > 0 => {
let name: String = detail.title.chars().take(keep).collect();
format!("{prefix}{name}…")
}
_ => full.chars().take(room).collect(),
}
}
#[cfg(test)]
mod tests {
use super::*;
@@ -596,20 +714,213 @@ mod tests {
.collect()
}
/// The column headings, which sit on the top border row.
///
/// That row alone, because the footer names done as well: a whole-screen search for
/// `done (0)` passes on the footer whether the column is drawn or not, which is how
/// three of these tests came to be vacuous the moment done was hidden.
fn headings(board: &Board, width: u16, height: u16) -> String {
render(board, width, height).remove(0)
}
fn footer(board: &Board, width: u16, height: u16) -> String {
render(board, width, height).pop().expect("no rows rendered")
}
/// The overlay's top border row, where the block title sits.
///
/// Counted in characters rather than bytes: the rows carry multi-byte glyphs.
fn overlay_title_row(lines: &[String], width: u16, height: u16) -> String {
let overlay = detail_overlay(Rect::new(0, 0, width, height));
lines[overlay.y as usize]
.chars()
.skip(overlay.x as usize)
.take(overlay.width as usize)
.collect()
}
#[test]
fn the_board_draws_the_four_statuses_as_columns() {
fn the_board_draws_the_four_statuses_as_columns_once_done_is_shown() {
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");
let mut board = Board::new(&dir).unwrap();
board.toggle_done(SCREEN);
let row = headings(&board, 120, 20);
for heading in ["backlog (1)", "committed (1)", "reviewing (0)", "done (0)"] {
assert!(screen.contains(heading), "no {heading:?} in:\n{screen}");
assert!(row.contains(heading), "no {heading:?} in:\n{row}");
}
}
/// Done only grows, and it is the column least often read. `ls` already leaves it
/// out of its listing while counting it in the summary; this is the same opinion.
#[test]
fn the_board_opens_with_the_done_column_hidden() {
let dir = board_dir();
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished one", "");
let board = Board::new(&dir).unwrap();
assert!(!board.show_done, "done was drawn at startup");
let row = headings(&board, 120, 20);
for heading in ["backlog (1)", "committed (0)", "reviewing (0)"] {
assert!(row.contains(heading), "no {heading:?} in:\n{row}");
}
assert!(!row.contains("done"), "done is still a column:\n{row}");
// Hidden, not unread: the count is right and revealing it needs no rescan.
assert_eq!(board.columns.len(), 4);
assert_eq!(board.visible().len(), 3);
assert_eq!(done_count(&board), 1);
assert!(
!render(&board, 120, 20).join("\n").contains("Finished one"),
"a hidden done ticket was drawn"
);
}
/// The three that are left take the width done was using, rather than leaving a gap.
#[test]
fn the_visible_columns_share_the_full_width() {
let dir = board_dir();
let mut board = Board::new(&dir).unwrap();
let hidden = headings(&board, 120, 20);
assert_eq!(hidden.matches('┌').count(), 3, "{hidden}");
assert!(hidden.ends_with('┐'), "the columns stop short of the edge:\n{hidden}");
board.toggle_done(SCREEN);
let shown = headings(&board, 120, 20);
assert_eq!(shown.matches('┌').count(), 4, "{shown}");
assert!(shown.ends_with('┐'), "{shown}");
}
/// Hiding is a prefix of the columns, which only holds while done is last. The
/// board leans on that, so the assumption is pinned rather than assumed.
#[test]
fn the_done_column_is_last() {
assert_eq!(status_dirs().last(), Some(&DONE));
}
#[test]
fn the_footer_names_the_key_and_carries_the_count_while_done_is_hidden() {
let dir = board_dir();
for (n, title) in [("44444444", "One"), ("55555555", "Two")] {
write_ticket(&dir, "done", &format!("{n}-0000-4000-8000-000000000000"), title, "");
}
let mut board = Board::new(&dir).unwrap();
let hidden = footer(&board, 120, 20);
assert!(hidden.contains("d show done (2)"), "{hidden}");
board.toggle_done(SCREEN);
let shown = footer(&board, 120, 20);
assert!(shown.contains("d hide done"), "{shown}");
// With the column drawn, its own heading carries the count.
assert!(!shown.contains("(2)"), "the count is printed twice:\n{shown}");
}
/// The modal footer names it too, since the key works with a ticket open.
#[test]
fn the_detail_footer_also_names_the_done_key() {
let dir = board_dir();
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
let mut board = Board::new(&dir).unwrap();
board.toggle_detail();
let row = footer(&board, 120, 20);
assert!(row.contains("d show done (0)"), "{row}");
assert!(row.contains("pgup/pgdn scroll"), "{row}");
}
/// Hiding the column under the selection has to move it, or it points at nothing.
#[test]
fn hiding_done_under_the_selection_moves_it_to_the_last_visible_column() {
let dir = board_dir();
write_ticket(&dir, "reviewing", "33333333-0000-4000-8000-000000000000", "Ready", "");
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished", "");
let mut board = Board::new(&dir).unwrap();
board.toggle_done(SCREEN);
board.select_column(3, SCREEN);
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Finished".to_string()));
board.toggle_done(SCREEN);
assert_eq!(board.column, 2, "the selection stayed on a column that is gone");
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Ready".to_string()));
}
/// And an open detail of a done ticket goes with it: showing a ticket that is no
/// longer on the board is worse than closing, and swapping it for a different
/// ticket without saying so is worse than both.
#[test]
fn hiding_done_closes_a_detail_view_of_a_done_ticket() {
let dir = board_dir();
write_ticket(&dir, "reviewing", "33333333-0000-4000-8000-000000000000", "Ready", "");
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished", "");
let mut board = Board::new(&dir).unwrap();
board.toggle_done(SCREEN);
board.select_column(3, SCREEN);
board.toggle_detail();
assert!(board.detail.is_some());
board.toggle_done(SCREEN);
assert!(board.detail.is_none(), "{:?}", board.detail);
}
/// A ticket being read in a column that is not going anywhere stays open.
#[test]
fn hiding_done_leaves_a_detail_view_of_another_ticket_open() {
let dir = board_dir();
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
let mut board = Board::new(&dir).unwrap();
board.toggle_detail();
board.toggle_done(SCREEN);
board.toggle_done(SCREEN);
assert!(board.detail.is_some(), "an unrelated detail view was closed");
}
/// Done is appended rather than inserted, so showing it moves nothing.
#[test]
fn showing_done_again_leaves_the_selection_where_it_was() {
let dir = board_dir();
write_ticket(&dir, "committed", "22222222-0000-4000-8000-000000000000", "Alpha", "");
write_ticket(&dir, "committed", "33333333-0000-4000-8000-000000000000", "Beta", "");
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished", "");
let mut board = Board::new(&dir).unwrap();
board.select_column(1, SCREEN);
board.select_card(1, SCREEN);
let (column, card) = (board.column, board.card);
board.toggle_done(SCREEN);
assert_eq!((board.column, board.card), (column, card));
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Beta".to_string()));
}
/// The selection cannot walk into a column that is not drawn.
#[test]
fn the_selection_stops_at_the_last_visible_column() {
let dir = board_dir();
write_ticket(&dir, "done", "44444444-0000-4000-8000-000000000000", "Finished", "");
let mut board = Board::new(&dir).unwrap();
board.select_column(9, SCREEN);
assert_eq!(board.column, 2);
assert!(board.selected().is_none(), "the selection reached the done column");
board.toggle_done(SCREEN);
board.select_column(9, SCREEN);
assert_eq!(board.column, 3);
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Finished".to_string()));
}
/// 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() {
@@ -630,12 +941,13 @@ mod tests {
fn an_empty_status_renders_as_an_empty_column() {
let dir = board_dir();
let board = Board::new(&dir).unwrap();
let mut board = Board::new(&dir).unwrap();
assert_eq!(board.columns.len(), 4);
let screen = render(&board, 120, 20).join("\n");
board.toggle_done(SCREEN);
let row = headings(&board, 120, 20);
for status in status_dirs() {
assert!(screen.contains(&format!("{status} (0)")), "{screen}");
assert!(row.contains(&format!("{status} (0)")), "{row}");
}
}
@@ -643,11 +955,13 @@ mod tests {
#[test]
fn a_missing_status_directory_is_still_a_column() {
let dir = board_dir();
std::fs::remove_dir_all(dir.join("done")).unwrap();
std::fs::remove_dir_all(dir.join(DONE)).unwrap();
let board = Board::new(&dir).unwrap();
let mut board = Board::new(&dir).unwrap();
assert_eq!(board.columns.len(), 4);
assert!(render(&board, 120, 20).join("\n").contains("done (0)"));
board.toggle_done(SCREEN);
assert!(headings(&board, 120, 20).contains("done (0)"));
}
#[test]
@@ -974,20 +1288,98 @@ mod tests {
assert!(board.detail.is_none());
board.toggle_detail();
let detail = board.detail.clone().expect("no detail");
let detail = board.detail.as_ref().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}");
assert!(detail.text.contains("A description."), "{}", detail.text);
assert!(detail.text.contains("Crit one"), "{}", detail.text);
assert!(detail.text.contains("A note from elsewhere."), "{}", detail.text);
assert!(detail.text.contains("bob"), "{}", detail.text);
// Plain text, since ratatui would print an escape as literal bytes
assert!(!detail.contains('\x1b'), "escapes reached the detail view: {detail:?}");
assert!(
!detail.text.contains('\x1b'),
"escapes reached the detail view: {:?}",
detail.text
);
board.toggle_detail();
assert!(board.detail.is_none());
}
/// The reported bug: the modal showed a description, criteria and a metadata
/// table belonging to a ticket it never named.
#[test]
fn the_detail_view_names_the_ticket_it_has_open() {
let dir = board_dir();
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", "First one", "");
let mut board = Board::new(&dir).unwrap();
board.toggle_detail();
let screen = render(&board, SCREEN.width, SCREEN.height);
let row = overlay_title_row(&screen, SCREEN.width, SCREEN.height);
assert!(row.contains("(1111111)"), "no short id on the border:\n{row}");
assert!(row.contains("First one"), "no title on the border:\n{row}");
// The heading stays out of the text: `show` prints it and here the border
// carries it, so it is on screen once rather than twice.
assert!(
!board.detail.as_ref().unwrap().text.contains("First one"),
"{:?}",
board.detail
);
}
/// Scrolled to the end of a long ticket, the name is still where it started.
#[test]
fn the_name_stays_on_screen_at_the_end_of_a_long_ticket() {
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 screen = render(&board, SCREEN.width, SCREEN.height);
assert!(screen.join("\n").contains("Line 060"), "nothing scrolled:\n{}", screen.join("\n"));
let row = overlay_title_row(&screen, SCREEN.width, SCREEN.height);
assert!(row.contains("(1111111)"), "the id scrolled away:\n{row}");
assert!(row.contains("First one"), "the title scrolled away:\n{row}");
}
/// A title longer than the overlay is cut to the border — corners intact, id
/// whole, ellipsis where the name gave up — not overrun and not dropped whole.
#[test]
fn a_long_title_is_cut_to_the_border_it_sits_on() {
let dir = board_dir();
// Long enough to pass the overlay's inner width many times over, short enough
// that its slug still fits a filename.
let title = format!("Head {} tailmarker", "filler ".repeat(20));
write_ticket(&dir, "backlog", "11111111-0000-4000-8000-000000000000", &title, "");
let mut board = Board::new(&dir).unwrap();
board.toggle_detail();
let screen = render(&board, SCREEN.width, SCREEN.height);
let row = overlay_title_row(&screen, SCREEN.width, SCREEN.height);
assert!(row.starts_with('┌'), "the left corner gave way:\n{row}");
assert!(row.ends_with('┐'), "the right corner gave way:\n{row}");
assert!(row.contains("(1111111)"), "the id did not survive the cut:\n{row}");
assert!(row.contains("Head"), "the border was left blank:\n{row}");
assert!(row.contains('…'), "the cut read as a complete title:\n{row}");
assert!(!row.contains("tailmarker"), "the title overran the border:\n{row}");
}
/// 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() {
@@ -997,7 +1389,7 @@ mod tests {
let mut board = Board::new(&dir).unwrap();
board.toggle_detail();
assert!(!board.detail.clone().unwrap().contains("A late note."));
assert!(!board.detail.as_ref().unwrap().text.contains("A late note."));
let comments = dir.join("comments").join(uuid);
std::fs::create_dir_all(&comments).unwrap();
@@ -1008,7 +1400,11 @@ mod tests {
.unwrap();
assert!(board.tick().unwrap(), "the tick saw no change");
assert!(board.detail.clone().unwrap().contains("A late note."), "{:?}", board.detail);
assert!(
board.detail.as_ref().unwrap().text.contains("A late note."),
"{:?}",
board.detail
);
}
#[test]
@@ -1129,13 +1525,21 @@ mod tests {
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);
// By id in the text: the heading is stripped from the body, and the title
// travels beside it for the block title instead.
assert!(
board.detail.as_ref().unwrap().text.contains("11111111"),
"{:?}",
board.detail
);
board.select_card(1, SCREEN);
assert_eq!(board.selected().map(|t| t.title.clone()), Some("Beta".to_string()));
assert!(board.detail.clone().unwrap().contains("22222222"), "{:?}", board.detail);
assert!(
board.detail.as_ref().unwrap().text.contains("22222222"),
"{:?}",
board.detail
);
}
/// A newly selected ticket starts at its own top, not where the last one was left.
@@ -1244,4 +1648,5 @@ mod tests {
assert_ne!(tui, ratatui::style::Color::Reset, "level {level} has no colour");
}
}
}
+30 -19
View File
@@ -189,7 +189,7 @@ pub fn slug(title: &str) -> String {
pub fn get_git_user() -> Option<String> {
std::process::Command::new("git")
.args(&["config", "user.name"])
.args(["config", "user.name"])
.output()
.ok()
.and_then(|out| {
@@ -256,7 +256,7 @@ pub fn resolve_ticket(search: &str, worklane_dir: &Path) -> Result<(String, Stri
let entries = fs::read_dir(&status_path)?;
for entry in entries.filter_map(|e| e.ok()) {
let path = entry.path();
if !path.extension().map_or(false, |e| e == "md") {
if !path.extension().is_some_and(|e| e == "md") {
continue;
}
let content = match fs::read_to_string(&path) {
@@ -326,16 +326,16 @@ pub fn format_comments_with(
}
let mut result = String::new();
result.push_str("\n");
result.push('\n');
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('\n');
result.push_str(&paint(&format!("From {} ({})", author, time), Color::Cyan, colored));
result.push_str("\n");
result.push('\n');
if !body.is_empty() {
result.push_str(&" ".to_string());
result.push_str(" ");
result.push_str(body);
}
result.push('\n');
@@ -429,17 +429,19 @@ pub fn content_trim(content: &str, colored: bool) -> String {
}
// Standard markdown link colorization in cyan
if line.contains("[") && line.contains("(") && line.contains("]") {
if let Some(start) = line.find("[") {
let bracket_text = &line[start..];
if let Some(end_bracket) = bracket_text.find("](") {
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(&paint(&line[start..absolute_end], Color::Cyan, colored));
result.push('\n');
continue;
}
if line.contains("[")
&& line.contains("(")
&& line.contains("]")
&& let Some(start) = line.find("[")
{
let bracket_text = &line[start..];
if let Some(end_bracket) = bracket_text.find("](") {
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(&paint(&line[start..absolute_end], Color::Cyan, colored));
result.push('\n');
continue;
}
}
}
@@ -453,7 +455,7 @@ pub fn content_trim(content: &str, colored: bool) -> String {
}
pub fn colorize_ordered(line: &str) -> String {
if line.chars().next().map_or(true, |c| !c.is_ascii_digit()) {
if line.chars().next().is_none_or(|c| !c.is_ascii_digit()) {
return line.to_string();
}
@@ -1093,9 +1095,18 @@ pub fn trim_blank_ends(values: &[String]) -> &[String] {
}
pub fn status_dirs() -> Vec<&'static str> {
vec!["backlog", "committed", "reviewing", "done"]
vec!["backlog", "committed", "reviewing", DONE]
}
/// The end of the flow, and the one status both views treat differently: `ls` counts it
/// in the summary and leaves it out of the listing, and the board hides its column until
/// asked. Named because that rule now has two readers.
///
/// It is deliberately last in `status_dirs()`. The board leans on that: hiding done drops
/// the final column, so the other three keep their indices and the selection only has to
/// be handled when it is sitting on done itself.
pub const DONE: &str = "done";
/// Lowest and highest level a ticket can carry. 1 is the most urgent, which is
/// what the `p1` to `p3` tags this replaced already meant.
pub const PRIORITY_RANGE: std::ops::RangeInclusive<u8> = 1..=5;
+21 -21
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::fixture::{PathChild, PathCreateDir};
use assert_fs::TempDir;
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
@@ -23,7 +23,7 @@ fn add_creates_ticket_in_backlog() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("add")
.args(["--title", "Test ticket"])
.assert()
@@ -46,7 +46,7 @@ fn add_formats_ticket_correctly() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args([
"add",
"--title",
@@ -103,7 +103,7 @@ fn add_joins_multiple_descriptions() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args([
"add",
"--title", "Multi desc ticket",
@@ -132,7 +132,7 @@ fn add_with_optional_fields_uses_defaults() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Minimal ticket"])
.assert()
.success();
@@ -156,13 +156,13 @@ fn add_allows_duplicate_titles() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Existing title"])
.assert()
.success();
let mut cmd2 = Command::cargo_bin(BIN_NAME).unwrap();
cmd2.current_dir(&temp.path())
cmd2.current_dir(temp.path())
.args(["add", "--title", "Existing title"])
.assert()
.success();
@@ -182,7 +182,7 @@ fn add_file_has_uuid_prefix() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "UUID test"])
.assert()
.success();
@@ -207,7 +207,7 @@ fn add_writes_the_priority_field() {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.args(["add", "--title", "Urgent thing", "--priority", "1"])
.assert()
.success();
@@ -227,7 +227,7 @@ fn add_leaves_priority_unset_when_omitted() {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.args(["add", "--title", "Whenever"])
.assert()
.success();
@@ -250,7 +250,7 @@ fn add_rejects_a_level_outside_the_range() {
// read as a flag.
for bad in ["0", "6", "high", "-1"] {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Bad level", &format!("--priority={bad}")])
.assert()
.failure();
@@ -272,7 +272,7 @@ fn add_accepts_prose_values_that_begin_with_a_hyphen() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "-t is a flag name"])
.args(["--description", "-x does nothing"])
.args(["--acceptance", "--print should be supported"])
@@ -300,7 +300,7 @@ fn add_still_accepts_the_equals_form() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title=-x equals form"])
.args(["--acceptance=--print via equals"])
.assert()
@@ -322,7 +322,7 @@ fn add_stores_a_title_that_is_only_hyphens() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", bare])
.assert()
.success();
@@ -344,7 +344,7 @@ fn add_still_rejects_a_mistyped_flag_on_a_non_prose_argument() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Mistyped", flag, "--bogus"])
.assert()
.failure();
@@ -363,7 +363,7 @@ fn add_rejects_arguments_after_a_bare_separator() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Sep", "--", "--title", "second"])
.assert()
.failure();
@@ -372,7 +372,7 @@ fn add_rejects_arguments_after_a_bare_separator() {
assert_eq!(count, 0);
}
fn only_ticket(worklane: &PathBuf) -> String {
fn only_ticket(worklane: &Path) -> String {
let files: Vec<_> = fs::read_dir(worklane.join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
@@ -390,7 +390,7 @@ fn add_keeps_a_paragraph_break_in_the_description() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Two Paras"])
.args(["--description", "First paragraph."])
.args(["--description", ""])
@@ -406,7 +406,7 @@ fn add_keeps_a_paragraph_break_in_the_description() {
// And it survives the round trip back out
let mut show = Command::cargo_bin(BIN_NAME).unwrap();
show.current_dir(&temp.path()).args(["show", "Two Paras"]);
show.current_dir(temp.path()).args(["show", "Two Paras"]);
let stdout = String::from_utf8(show.assert().success().get_output().stdout.clone()).unwrap();
assert!(
stdout.contains("First paragraph.\n\nSecond paragraph."),
@@ -421,7 +421,7 @@ fn add_discards_blank_descriptions_at_either_end() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Padded"])
.args(["--description", ""])
.args(["--description", " "])
@@ -444,7 +444,7 @@ fn add_treats_an_all_blank_description_as_none() {
let worklane = setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["add", "--title", "Blank"])
.args(["--description", ""])
.args(["--description", " "])
+4 -4
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
const UUID: &str = "475534a3-8a0d-45cb-9a97-39c251dd8e39";
@@ -20,7 +20,7 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
/// One criterion already ticked, one handwritten line inside the section, and a
/// checkbox in the description that must not be counted as a criterion.
fn create_ticket(worklane: &PathBuf) {
fn create_ticket(worklane: &Path) {
// Written without line continuations on purpose: a trailing `\` strips the next
// line's leading whitespace, so the indented line would arrive unindented and the
// test would prove nothing about preserving it.
@@ -55,11 +55,11 @@ fn create_ticket(worklane: &PathBuf) {
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.current_dir(temp.path()).args(args);
cmd.assert().get_output().clone()
}
fn ticket(worklane: &PathBuf) -> String {
fn ticket(worklane: &Path) -> String {
fs::read_to_string(worklane.join("backlog").join(format!("{}_check-me.md", UUID))).unwrap()
}
+16 -16
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::fixture::{PathChild, PathCreateDir};
use assert_fs::TempDir;
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
@@ -18,7 +18,7 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
}
fn create_ticket(
worklane_dir: &PathBuf,
worklane_dir: &Path,
status: &str,
title: &str,
) -> String {
@@ -53,7 +53,7 @@ fn comment_creates_file_with_valid_ticket_uuid() {
let uuid = create_ticket(&worklane, "backlog", "Test Ticket");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "This is a test comment"])
.assert()
@@ -78,7 +78,7 @@ fn comment_creates_file_with_valid_ticket_title() {
create_ticket(&worklane, "committed", "My Ticket");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args(["My Ticket", "Testing title lookup"])
.assert()
@@ -105,7 +105,7 @@ fn comment_includes_git_user_and_body() {
let uuid = create_ticket(&worklane, "backlog", "Comment Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "My comment body"])
.assert()
@@ -129,7 +129,7 @@ fn comment_stored_in_timestamped_file() {
let uuid = create_ticket(&worklane, "done", "Timestamp Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Timestamp test"])
.assert()
@@ -156,7 +156,7 @@ fn comment_creates_comments_directory() {
assert!(!comments_dir.exists());
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Create dir test"])
.assert()
@@ -173,7 +173,7 @@ fn comment_uses_owner_flag_when_provided() {
let uuid = create_ticket(&worklane, "backlog", "Owner Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Test comment with owner"])
.arg("-o")
@@ -198,7 +198,7 @@ fn comment_falls_back_to_git_user_when_owner_omitted() {
let uuid = create_ticket(&worklane, "done", "Fallback Test");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("comment")
.args([&uuid, "Test comment fallback"])
.assert()
@@ -225,7 +225,7 @@ fn comments_added_back_to_back_are_both_kept() {
for body in ["first comment", "second comment", "third comment"] {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.arg("comment")
.args([&uuid, body])
.assert()
@@ -241,7 +241,7 @@ fn comments_added_back_to_back_are_both_kept() {
// And show has to render them in the order they were added
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg(&uuid);
cmd.current_dir(temp.path()).arg("show").arg(&uuid);
let assert = cmd.assert().success();
let stdout = String::from_utf8(assert.get_output().stdout.clone()).unwrap();
@@ -261,7 +261,7 @@ fn comment_accepts_a_body_that_begins_with_a_hyphen() {
for body in ["--print is the flag I mean", "-f skips the check", "-"] {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["comment", &uuid, body])
.assert()
.success();
@@ -289,13 +289,13 @@ fn comment_needs_a_separator_for_a_hyphen_leading_ticket() {
let mut without = Command::cargo_bin(BIN_NAME).unwrap();
without
.current_dir(&temp.path())
.current_dir(temp.path())
.args(["comment", "-leading", "a body"])
.assert()
.failure();
let mut with = Command::cargo_bin(BIN_NAME).unwrap();
with.current_dir(&temp.path())
with.current_dir(temp.path())
.args(["comment", "--", "-leading", "a body"])
.assert()
.success();
@@ -315,7 +315,7 @@ fn a_bare_double_hyphen_body_needs_a_separator() {
let mut without = Command::cargo_bin(BIN_NAME).unwrap();
let assert = without
.current_dir(&temp.path())
.current_dir(temp.path())
.args(["comment", &uuid, "--"])
.assert()
.failure();
@@ -327,7 +327,7 @@ fn a_bare_double_hyphen_body_needs_a_separator() {
);
let mut with = Command::cargo_bin(BIN_NAME).unwrap();
with.current_dir(&temp.path())
with.current_dir(temp.path())
.args(["comment", &uuid, "--", "--"])
.assert()
.success();
+96
View File
@@ -0,0 +1,96 @@
use assert_cmd::Command;
use assert_fs::TempDir;
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
/// The document as this test's binary carries it, so the print path is pinned to the
/// file in the repo rather than to a description of it.
const SKILL: &str = include_str!("../assets/SKILL.md");
/// `HOME` is redirected, so the suite never writes into the home of whoever runs it.
/// A temp directory rather than the real one is also what makes the already-installed
/// and the modified cases reachable at all.
fn run(home: &TempDir, args: &[&str]) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.env("HOME", home.path()).args(args);
cmd.assert().get_output().clone()
}
fn installed(home: &TempDir) -> std::path::PathBuf {
home.path().join(".claude/skills/worklane/SKILL.md")
}
/// Nothing about the skill needs a board, and it is wanted before there is one.
#[test]
fn the_skill_installs_outside_a_worklane_directory() {
let home = TempDir::new().unwrap();
let out = run(&home, &["install-skill"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(out.status.code(), Some(0), "{stdout}");
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
assert!(stdout.contains(".claude/skills/worklane/SKILL.md"), "{stdout}");
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
}
#[test]
fn a_second_install_says_it_is_already_up_to_date() {
let home = TempDir::new().unwrap();
run(&home, &["install-skill"]);
let out = run(&home, &["install-skill"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(out.status.code(), Some(0), "{stdout}");
assert!(stdout.contains("Already up to date"), "{stdout}");
}
/// A copy someone edited is theirs. The command says what to do next rather than
/// discarding it, and only `--force` overwrites.
#[test]
fn a_modified_copy_is_reported_and_needs_force() {
let home = TempDir::new().unwrap();
run(&home, &["install-skill"]);
std::fs::write(installed(&home), "hand written\n").unwrap();
let out = run(&home, &["install-skill"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert_eq!(out.status.code(), Some(0), "{stdout}");
assert!(stdout.contains("Differs from the version in this binary"), "{stdout}");
assert!(stdout.contains("--force"), "{stdout}");
assert!(stdout.contains("--print"), "the message never says how to compare: {stdout}");
assert_eq!(
std::fs::read_to_string(installed(&home)).unwrap(),
"hand written\n",
"the modified copy was overwritten anyway"
);
let out = run(&home, &["install-skill", "--force"]);
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
}
/// The print path is what makes a modified copy diffable, so it has to be the document
/// byte for byte and it must not install anything on the way past.
#[test]
fn print_writes_the_document_to_stdout_and_installs_nothing() {
let home = TempDir::new().unwrap();
let out = run(&home, &["install-skill", "--print"]);
assert_eq!(out.status.code(), Some(0));
assert_eq!(String::from_utf8_lossy(&out.stdout), SKILL);
assert!(!installed(&home).exists(), "--print installed the skill anyway");
}
/// The command has to be findable by someone who does not already know it exists.
#[test]
fn the_help_lists_the_install_skill_command() {
let home = TempDir::new().unwrap();
let stdout = String::from_utf8_lossy(&run(&home, &["--help"]).stdout).to_string();
assert!(stdout.contains("install-skill"), "{stdout}");
}
+14 -14
View File
@@ -17,7 +17,7 @@ fn setup_worklane(temp: &TempDir) -> std::path::PathBuf {
}
fn create_ticket(
worklane_dir: &std::path::PathBuf,
worklane_dir: &std::path::Path,
status: &str,
title: &str,
owner: &str,
@@ -71,7 +71,7 @@ fn ls_without_status_shows_overview() {
create_ticket(&worklane, "done", "Feature D", "dave", "2026-09-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").assert().success();
cmd.current_dir(temp.path()).arg("ls").assert().success();
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("BACKLOG"));
@@ -94,7 +94,7 @@ fn ls_with_status_filters_tickets() {
create_ticket(&worklane, "reviewing", "Feature C", "charlie", "2026-08-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").args(["committed"]);
cmd.current_dir(temp.path()).arg("ls").args(["committed"]);
cmd.assert().success();
@@ -107,7 +107,7 @@ fn ls_with_invalid_status_fails() {
let temp = TempDir::new().unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["nonexistent"])
.assert()
@@ -124,7 +124,7 @@ fn ls_listed_tickets_sorted_alphabetically() {
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-08-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["backlog"])
.assert()
@@ -146,7 +146,7 @@ fn ls_empty_status_shows_message() {
// Intentionally leave "done" empty
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["done"])
.assert()
@@ -164,7 +164,7 @@ fn ls_displays_owner_and_due() {
create_ticket(&worklane, "backlog", "Test ticket", "alice", "2026-12-31");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("ls")
.args(["backlog"])
.assert()
@@ -191,7 +191,7 @@ fn ls_handles_short_and_non_ascii_filenames() {
}
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").arg("backlog").assert().success();
cmd.current_dir(temp.path()).arg("ls").arg("backlog").assert().success();
let stdout = get_stdout(&mut cmd);
assert_eq!(stdout.matches("Odd Name").count(), 3);
@@ -209,7 +209,7 @@ fn ls_survives_a_malformed_created_at() {
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").arg("backlog").assert().success();
cmd.current_dir(temp.path()).arg("ls").arg("backlog").assert().success();
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Bad Date"));
@@ -217,7 +217,7 @@ fn ls_survives_a_malformed_created_at() {
assert!(!stdout.contains("日本語"));
}
fn create_ticket_with_priority(worklane_dir: &std::path::PathBuf, title: &str, priority: &str) {
fn create_ticket_with_priority(worklane_dir: &std::path::Path, title: &str, priority: &str) {
let slug: String = title.to_lowercase().replace(' ', "-");
let body = format!(
"# {}\n\n## Metadata\n\n- **ID**: 00000000-0000-0000-0000-00000000000{}\n\
@@ -242,7 +242,7 @@ fn ls_sorts_by_priority_then_title() {
create_ticket(&worklane, "backlog", "No priority at all", "alice", "_Not set_");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").arg("backlog");
cmd.current_dir(temp.path()).arg("ls").arg("backlog");
let stdout = get_stdout(&mut cmd);
let at = |needle: &str| stdout.find(needle).unwrap_or_else(|| panic!("{needle} missing"));
@@ -261,7 +261,7 @@ fn ls_filters_by_priority_and_composes_with_status() {
create_ticket_with_priority(&worklane, "Lower one", "3");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["ls", "backlog", "--priority", "1"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Urgent one"));
@@ -269,7 +269,7 @@ fn ls_filters_by_priority_and_composes_with_status() {
// Same filter without a status, through the grouped listing
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).args(["ls", "--priority", "3"]);
cmd.current_dir(temp.path()).args(["ls", "--priority", "3"]);
let stdout = get_stdout(&mut cmd);
assert!(stdout.contains("Lower one"));
assert!(!stdout.contains("Urgent one"));
@@ -285,7 +285,7 @@ fn ls_shows_a_mark_for_the_level() {
create_ticket(&worklane, "backlog", "Nothing set", "alice", "_Not set_");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("ls").arg("backlog");
cmd.current_dir(temp.path()).arg("ls").arg("backlog");
let stdout = get_stdout(&mut cmd);
// Piped, so no escapes: the glyph is carrying the level by itself
+23 -18
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
@@ -17,8 +17,13 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
worklane.path().to_path_buf()
}
/// Every metadata field a ticket has, positionally. The lint is right that the call
/// site reads as a wall of strings, and the fix is a struct with named fields, but
/// that is a change to thirteen call sites in this file alone and belongs in its own
/// commit rather than in a warning sweep.
#[allow(clippy::too_many_arguments)]
fn create_ticket(
worklane_dir: &PathBuf,
worklane_dir: &Path,
status: &str,
title: &str,
description: &str,
@@ -89,7 +94,7 @@ fn mv_forwards_from_backlog_to_committed() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -133,7 +138,7 @@ fn mv_blocks_backward_move() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -163,7 +168,7 @@ fn mv_allows_backward_move_with_force() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -197,7 +202,7 @@ fn mv_blocks_nonsequential_forward_move() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -227,7 +232,7 @@ fn mv_allows_skipping_stages_with_force() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -259,7 +264,7 @@ fn mv_ignores_already_in_same_status() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -290,7 +295,7 @@ fn mv_rejects_invalid_status() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -320,7 +325,7 @@ fn mv_uses_ticket_id_for_resolution() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -354,7 +359,7 @@ fn mv_keeps_status_in_sync_across_consecutive_moves() {
for target in ["committed", "reviewing"] {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -392,7 +397,7 @@ fn mv_repairs_legacy_status_field() {
Command::cargo_bin(BIN_NAME)
.unwrap()
.current_dir(&temp.path())
.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -415,7 +420,7 @@ fn mv_fails_when_status_field_is_missing() {
fs::write(&path, "# No Status\n\n## Metadata\n\n- **Owner**: jack\n").unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("mv")
.arg("abc123def4567")
.arg("--status")
@@ -498,7 +503,7 @@ fn mv_never_leaves_stale_content_in_the_target_directory() {
chmod(&source, 0o444);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.success();
@@ -541,7 +546,7 @@ fn mv_leaves_the_ticket_in_one_place_when_the_move_fails() {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
let assert = cmd
.current_dir(&temp.path())
.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.failure();
@@ -569,7 +574,7 @@ fn mv_leaves_the_ticket_in_one_place_when_the_move_fails() {
let mut retry = Command::cargo_bin(BIN_NAME).unwrap();
retry
.current_dir(&temp.path())
.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.success();
@@ -595,7 +600,7 @@ fn mv_leaves_nothing_behind_on_success() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["mv", "abc123def4567", "--status", "committed"])
.assert()
.success();
@@ -625,7 +630,7 @@ fn mv_moves_the_resolved_ticket_when_two_share_a_title() {
}
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.args(["mv", "22222222", "--status", "committed"])
.assert()
.success();
+6 -6
View File
@@ -2,7 +2,7 @@ use assert_cmd::Command;
use assert_fs::TempDir;
use assert_fs::fixture::{PathChild, PathCreateDir};
use std::fs;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
const UUID: &str = "475534a3-8a0d-45cb-9a97-39c251dd8e39";
@@ -20,7 +20,7 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
/// A fully populated ticket, with one criterion already ticked and a section the tool
/// knows nothing about, so every test can check both survive.
fn create_ticket(worklane: &PathBuf) -> String {
fn create_ticket(worklane: &Path) -> String {
let filename = format!("{}_original-title.md", UUID);
fs::write(
worklane.join("backlog").join(&filename),
@@ -61,11 +61,11 @@ fn create_ticket(worklane: &PathBuf) -> String {
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.current_dir(temp.path()).args(args);
cmd.assert().get_output().clone()
}
fn ticket(worklane: &PathBuf) -> String {
fn ticket(worklane: &Path) -> String {
let entry = fs::read_dir(worklane.join("backlog"))
.unwrap()
.filter_map(|e| e.ok())
@@ -74,7 +74,7 @@ fn ticket(worklane: &PathBuf) -> String {
fs::read_to_string(entry.path()).unwrap()
}
fn stray_files(worklane: &PathBuf) -> Vec<String> {
fn stray_files(worklane: &Path) -> Vec<String> {
fs::read_dir(worklane)
.unwrap()
.filter_map(|e| e.ok())
@@ -327,7 +327,7 @@ fn append_replaces_an_empty_section_rather_than_following_its_placeholder() {
let worklane = setup_worklane(&temp);
let mut add = Command::cargo_bin(BIN_NAME).unwrap();
add.current_dir(&temp.path())
add.current_dir(temp.path())
.args(["add", "--title", "Bare ticket"])
.assert()
.success();
+20 -17
View File
@@ -16,8 +16,11 @@ fn setup_worklane(temp: &TempDir) -> std::path::PathBuf {
worklane.path().to_path_buf()
}
/// Same fixture, same trade as `cmd_mv.rs`: positional today, a struct when the call
/// sites in both files are converted together.
#[allow(clippy::too_many_arguments)]
fn create_ticket(
worklane_dir: &std::path::PathBuf,
worklane_dir: &std::path::Path,
status: &str,
title: &str,
description: &str,
@@ -86,7 +89,7 @@ fn show_displays_ticket_by_full_uuid() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("abc123def456789012345678901234567890")
.assert()
@@ -118,7 +121,7 @@ fn show_displays_ticket_by_partial_uuid() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("abc123def4567890")
.assert()
@@ -147,7 +150,7 @@ fn show_displays_ticket_by_title() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("login")
.assert()
@@ -178,7 +181,7 @@ fn show_displays_ticket_by_partial_title() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("fix")
.assert()
@@ -206,7 +209,7 @@ fn show_shows_both_uuid_and_title_in_output() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("test")
.assert()
@@ -222,7 +225,7 @@ fn show_fails_for_nonexistent_ticket() {
setup_worklane(&temp);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("nonexistent")
.assert()
@@ -259,7 +262,7 @@ fn show_asks_for_disambiguation_when_multiple_matches() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("est");
cmd.current_dir(temp.path()).arg("show").arg("est");
let stderr = get_stderr(&mut cmd);
assert!(stderr.contains("Multiple tickets found"));
@@ -299,7 +302,7 @@ fn show_reports_ambiguity_on_stderr_with_a_failing_exit() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("ambiguous")
.assert()
@@ -333,7 +336,7 @@ fn show_disambiguates_tickets_with_short_filenames() {
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("short");
cmd.current_dir(temp.path()).arg("show").arg("short");
let stderr = get_stderr(&mut cmd);
assert!(stderr.contains("Multiple tickets found"));
@@ -356,7 +359,7 @@ fn show_disambiguates_tickets_with_non_ascii_filenames() {
}
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("accented");
cmd.current_dir(temp.path()).arg("show").arg("accented");
let stderr = get_stderr(&mut cmd);
assert!(stderr.contains("Multiple tickets found"));
@@ -383,7 +386,7 @@ fn show_searches_across_all_statuses() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path())
cmd.current_dir(temp.path())
.arg("show")
.arg("committed")
.assert()
@@ -408,7 +411,7 @@ fn show_renders_the_priority_mark_beside_the_number() {
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("Prio");
cmd.current_dir(temp.path()).arg("show").arg("Prio");
let stdout = get_stdout(&mut cmd);
// Mark for the eye, number still there for the file's sake
@@ -438,7 +441,7 @@ fn show_prints_the_title_once() {
);
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("Once Only");
cmd.current_dir(temp.path()).arg("show").arg("Once Only");
let stdout = get_stdout(&mut cmd);
assert_eq!(
@@ -467,7 +470,7 @@ fn show_renders_the_metadata_as_an_aligned_table() {
.unwrap();
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg("Table");
cmd.current_dir(temp.path()).arg("show").arg("Table");
let stdout = get_stdout(&mut cmd);
// Every value starts in the same column, sized by the longest field name
@@ -500,7 +503,7 @@ fn ticket_with(worklane: &std::path::Path, status: &str, uuid: &str, title: &str
fn show(temp: &TempDir, search: &str) -> std::process::Output {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(&temp.path()).arg("show").arg(search);
cmd.current_dir(temp.path()).arg("show").arg(search);
cmd.assert().get_output().clone()
}
@@ -546,7 +549,7 @@ fn show_resolves_the_short_id_the_listing_prints() {
ticket_with(&worklane, "backlog", uuid, "Alpha", "alpha");
let mut ls = Command::cargo_bin(BIN_NAME).unwrap();
ls.current_dir(&temp.path()).args(["ls", "backlog"]);
ls.current_dir(temp.path()).args(["ls", "backlog"]);
let listing = String::from_utf8(ls.assert().success().get_output().stdout.clone()).unwrap();
// Take the id exactly as printed, so this couples to the display width rather
+1 -1
View File
@@ -15,7 +15,7 @@ fn setup_worklane(temp: &TempDir) {
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.current_dir(temp.path()).args(args);
cmd.assert().get_output().clone()
}