Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3085b0226f | ||
|
|
b56b31d2d9 | ||
|
|
e6fe51e31e | ||
|
|
c606b5ba43 | ||
|
|
90b313952b | ||
|
|
7240fc263b | ||
|
|
580e3cf7f0 | ||
|
|
2298d3373a | ||
|
|
8013c2b74d | ||
|
|
6178d7bd3d | ||
|
|
f740e42d1c |
@@ -112,8 +112,8 @@ criteria and handwritten sections are left alone. At least one field is required
|
||||
**Options:** `--title`, `--description` (or `-d`), `--acceptance` (or `-a`), `--plan`
|
||||
(or `-p`), `--tags` (or `-g`), `--due`, `--priority`
|
||||
|
||||
Owner is not settable here, and neither is status: `mv` owns status. Changing the
|
||||
title renames the file, keeping the UUID.
|
||||
Owner is not settable here, and neither is status: `chown` owns owner and `mv` owns
|
||||
status. Changing the title renames the file, keeping the UUID.
|
||||
|
||||
```bash
|
||||
worklane set a1b2c3d4 --priority 1
|
||||
@@ -138,6 +138,25 @@ worklane append a1b2c3d4 -a "One more criterium"
|
||||
worklane append a1b2c3d4 -p "A later step"
|
||||
```
|
||||
|
||||
### `worklane chown`
|
||||
|
||||
Set the owner of a ticket. The only command that writes the Owner field: `set` does
|
||||
not offer it.
|
||||
|
||||
**Positional arguments:**
|
||||
- `<user>`: The new owner. Free text, checked against nothing
|
||||
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
|
||||
|
||||
The user comes first and the ticket second, after Unix `chown`. That is the one
|
||||
command here that does not start with the ticket, so mind the order: swap the two and
|
||||
the call fails, because the username has to resolve as a ticket. An owner set to the
|
||||
value it already holds is reported unchanged and nothing is written.
|
||||
|
||||
```bash
|
||||
worklane chown alice a1b2c3d4
|
||||
worklane chown "Ansho Rei" "A clearer title"
|
||||
```
|
||||
|
||||
### `worklane check` and `worklane uncheck`
|
||||
|
||||
Tick or untick a single acceptance criterion. Every other criterion keeps its state,
|
||||
|
||||
@@ -395,6 +395,33 @@ export const append = tool({
|
||||
},
|
||||
});
|
||||
|
||||
export const chown = tool({
|
||||
description:
|
||||
"Change the owner of a worklane ticket. This is the only writer of the Owner field: set does not offer it. The user is free text and is checked against nothing. Note the argument order, user first and ticket second, after Unix chown.",
|
||||
args: {
|
||||
user: tool.schema
|
||||
.string()
|
||||
.describe("New owner (required). Free text, checked against nothing."),
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
},
|
||||
async execute(args: Record<string, any>, context: ToolContext) {
|
||||
if (!args.user) {
|
||||
return "Error changing owner: user is required";
|
||||
}
|
||||
if (!args.ticket) {
|
||||
return "Error changing owner: ticket is required";
|
||||
}
|
||||
|
||||
try {
|
||||
return await run(["chown", args.user, args.ticket], context);
|
||||
} catch (err: any) {
|
||||
return `Error changing owner: ${err.message}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* check and uncheck differ only in the verb, so the tool is built once.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
@@ -55,7 +57,9 @@ front is the same two commands in a more useful order.
|
||||
|
||||
### Editing a Ticket
|
||||
- `set` replaces a field, `append` adds to a section. The verb carries the meaning, so no flag needs a replace-or-append prefix, and `append` only offers the sections that hold multiple lines
|
||||
- **One field, one writer.** `set` has no `--owner` (that is `chown`'s, once it exists) and no `--status` (that is `mv`'s). Do not add either
|
||||
- **One field, one writer.** `set` has no `--owner` (that is `chown`'s) and no `--status` (that is `mv`'s). Do not add either
|
||||
- `chown` takes the **user first and the ticket second**, after Unix `chown`, and is the only command that does not start with the ticket. Deliberate: the name borrows the Unix association, so the order borrows it too. A swap is left to `resolve_ticket`, which refuses a bare username as a ticket. No argument is inspected to see whether it *also* names a ticket, since such a check would only fire where resolution already fails and would stay silent on the one case it cannot catch, a ticket whose title is the username
|
||||
- `cmd_chown` is `set_metadata_field` plus `save_ticket`, with the same whole-file no-op comparison `set` uses and the same `report()` output, so nothing about writing a field lives twice
|
||||
- Sections are a table in `util.rs`: `DESCRIPTION`, `ACCEPTANCE`, `PLAN`, each with a heading, a label, the placeholder `add` writes when empty, and a `SectionKind`. Adding a section later is one entry, not edits in both commands
|
||||
- Everything is targeted line surgery, never a regenerated file. That is what keeps a ticked criterion ticked and a handwritten `## Notes` section intact when an unrelated field changes. `section_body()` finds the lines to touch, `set_metadata_line()` does the metadata, and every other byte is copied through
|
||||
- Appending to a numbered section continues from the count of steps already there and does not renumber what is above it, so a handwritten line in the section survives exactly as written
|
||||
@@ -75,6 +79,19 @@ front is the same two commands in a more useful order.
|
||||
- With the criterion omitted: prompt when stdin is a terminal, otherwise return the numbered list as an error. Never prompt unconditionally, the opencode wrapper has no tty and would block on a stdin that never closes. This is the same choice `resolve_ticket` makes for an ambiguous match, and for the same reason
|
||||
- `show` numbers the criteria as `1. [x] text`, so the index is visible where the ticket is read. The number replaces the list marker rather than joining it
|
||||
|
||||
### Relating Tickets
|
||||
|
||||
- **The Relations section is `relate`'s alone.** `RELATIONS` is in the section table but deliberately out of `section_args`, so `set` and `append` cannot reach it: a relation names a target that has to be resolved to a uuid first, and a prose flag would let an unresolvable line into the one section that is read back by machine. Same rule as Owner and Status, one field one writer
|
||||
- **`add` does not write the section.** The plan on 4179958 asked for it in the ticket writer; it is out on purpose. A `_No relations._` block in every new ticket is noise in every `show`, and the insertion path has to exist regardless for every ticket written before the section did, so leaving it out means one path that is always exercised rather than two
|
||||
- **The full uuid is stored, not the seven characters `ls` prints.** It resolves without a scan and cannot turn ambiguous as the board grows. `show` renders the short id and the target's title instead: the file is the machine's copy, the output is the reader's
|
||||
- **One direction is stored and the inverse is derived.** `blocked by` goes on the gated ticket rather than `blocks` on the blocker, because the gated ticket is the one whose move is refused and whose author knows about the dependency. `relates to` is symmetric and is written once, on whichever end the caller ran it from. `RelationIndex::inbound` finds the far end by scanning, which is what keeps `relate` a single-file write
|
||||
- **A line in the section that is not a relation is an error naming the ticket**, not a line quietly dropped. Nothing but `relate` writes there, so a bad line means a hand-edited file. The TUI is the deliberate exception: `detail_of` falls back to no block, since one corrupt ticket must not take the whole board down
|
||||
- **The block is built outside `content_trim` and passed in.** Half of it comes from other tickets and `content_trim` has only the body. It is spliced over the stored lines where the file has the section, and injected ahead of the metadata where it does not, because a ticket that is only pointed at has no section of its own and still has relations to show
|
||||
- `ensure_section` inserts against `SECTION_ORDER`, before the first following section that is actually in the file, and adds no blank line that was not already there. A handwritten `## Notes` between the plan and the metadata therefore keeps its place, and Metadata is in that list as an anchor rather than as something anything appends to
|
||||
- **The blocker check runs on every move**, after the already-in-that-status return and behind `force`. An open blocker is a reason not to start and a reason not to finish, and one rule is easier to hold than a table of which transitions care. A move to the status the ticket is already in is not a move, so it is not refused. `-f` now bypasses three rules, which is the right home for it: each one is a deliberate override of something the board would otherwise keep true
|
||||
- **A blocker that is not on the board warns and allows the move.** Refusing would wedge the ticket with no way out but `-f`, and a uuid nothing carries is a bookkeeping fault rather than a dependency. The refusal names **every** open blocker, since clearing the one that happened to be printed would leave the ticket blocked
|
||||
- Left out on purpose: removing a relation, which 4179958 assigns to 74904dc, and a blocked marker on the TUI card, which is its own ticket. Nothing on a card is worth a scan of the board per tick until the card is designed for it
|
||||
|
||||
### The Board View
|
||||
- `worklane` with no subcommand and `worklane tui` both open it, the way a bare `frig` does. `Cli::command` is therefore an `Option`
|
||||
- The worklane directory is looked for **before** the terminal, so running outside one gives the usual "No .worklane directory found" rather than a complaint about the tty. Both errors stay reachable and both are testable without a pty
|
||||
@@ -90,13 +107,54 @@ 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
|
||||
- **A card is four corners with the title between them:** mark and short id top left, due top right, owner bottom left, criteria count bottom right. The two numbers are in corners because that is where the eye goes for one, and both were invisible at the end of a line of prose
|
||||
- The title takes one row or two, wrapped on spaces, with an ellipsis when even two are not enough. One row when one is enough: a second, blank row on every short ticket spends the column's height on nothing
|
||||
- **A card's height therefore depends on the column's width**, so `card_lines` and `card_height` both take it. `column_areas` is shared between the draw and `follow_selection` for the same reason: `Ratio` hands the remainder column to whichever slot it likes, and reproducing that arithmetic by hand is how the measurement and the draw come to disagree about where a card starts
|
||||
- **A corner that will not fit is dropped whole**, never truncated or wrapped: half a date reads as a different date, and a card that reflows in a narrow column changes height, which the scroll would then have to chase. The left corner is the ticket's identity and always stays
|
||||
- The criteria count is a field on `TicketItem`, filled in `collect_ticket_items` where the file is already being read, and counted through `criteria()` so a checkbox in a description is not counted here or numbered by `show`. Do not count per card: that re-reads every ticket body on every draw instead of on the tick that changed something. `None` rather than `[0/0]` for a ticket with no criteria
|
||||
- `due_date` cuts a due value back to its date only when it has one. The field is not validated (daa0e79), so it can hold a time or free text, and taking the first word regardless would turn "next friday" into "next"
|
||||
- **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. `headings()` locates the row through `board_area()` rather than taking row zero, since the tab row sits above it when more than one board is monitored
|
||||
|
||||
### Monitoring Several Boards
|
||||
- `worklane tui <path>...` takes any number of paths, each resolved through `find_worklane_dir` the way the working directory is: the first `.worklane` at or above it. No path is the working directory, so a bare `worklane` and `worklane tui` are unchanged
|
||||
- The failure **names the path** that had no board, since with several arguments "No .worklane directory found" does not say which one was wrong. Only when a path was given: a bare `worklane` has no path to name and keeps the message every other command gives, which is what its integration test asserts
|
||||
- Two paths inside one project resolve to the same `.worklane` and are monitored once. `projects()` dedupes on the resolved directory, not on the argument
|
||||
- **`Tab` owns the selection**, `column`, `card` and `offsets`, not `Board`. Sharing them across projects would point the selection at whatever unrelated ticket sat at the same place in the tab you switched to. `Board::current()` is the tab in view, and `show_done` stays on the board because it is a preference about the flow rather than about a project
|
||||
- The tabs are fixed for the run: a project cannot be added or dropped without restarting, so `Board::new` builds the tab list once and `reload` only refills each tab's columns. `reload` clamps **every** tab, and `select_tab` clamps again on arrival, because done may have been hidden while another tab was in view
|
||||
- The merge tab goes **first** and is where the view opens: it is the reason to monitor several boards at once. It is materialised in `reload`, from the cards already read, rather than computed per draw — the same reason the criteria count is filled in `collect_ticket_items`
|
||||
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. That comparator is exported for this and is the one `collect_ticket_items` uses, so the two orders cannot drift
|
||||
- `Card` wraps a `TicketItem` with the project it came from, `Some` only on the merge tab. Decided at reload rather than passed down to `card_lines` as a "which tab is this" flag. `TicketItem` is therefore `Clone`: the merge holds a second copy rather than re-reading every tree
|
||||
- **The project follows the id, on the card and on the overlay border.** Across boards the id is not an address: two projects can hold the same title, and seven characters do not say where they live. `project_label` takes what the row has left after the mark and the id and ends in an ellipsis, and it is measured before the due date, so on the merge the project wins the narrow column and the date is what `corner_line` drops
|
||||
- `tab` and `shift+tab` cycle rather than clamp, unlike the cards and columns: a row of tabs is a ring, and there is no end of a list to run off. Both were free of every other binding — the columns took `hjkl` and the arrows
|
||||
- **The tab row is drawn only when there is more than one board**, so a single board is the view it has always been. `frame_rows()` gives it `Length(0)` otherwise, which keeps the row indices the same for both cases and is shared with `card_width` and `column_text_height` for the reason `column_areas` is: geometry reproduced by hand drifts from the draw
|
||||
- `digest_of` hashes each board's `digest` into one value, so a change in any of them redraws. Do not watch only the first
|
||||
|
||||
### 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
|
||||
- **`color_text()` is for the CLI's own printing only. Anything reachable from `content_trim` takes the decision as an argument and calls `paint()`**, because the board renders with colour off and an escape sequence in a ratatui paragraph is drawn as literal bytes. `nothing_the_body_renders_asks_the_terminal_for_the_colour_decision` scans this file and fails on a new caller; the allowlist is `ambiguous`, which builds a failed-search message for stderr
|
||||
- A function that takes an `enabled` flag must use it all the way down. `colorize_bold` honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function
|
||||
- **A test that asserts an absence has to be paired with one that asserts the presence.** The guard for this, an assert that the detail view holds no escape byte, could not fail: a test binary has no tty, so `should_use_colors()` was false and the leaking branch was never taken. The pair is now `content_trim(.., false)` has no escape and `content_trim(.., true)` still colours, which pins the flag as the only thing that decides
|
||||
- **The palette is the `Color` enum, not a string.** `Color::ansi()` gives the CLI its SGR sequence and `From<Color> for ratatui::style::Color` gives the TUI its equivalent, so a colour that exists for one renderer and not the other is a compile error. The stringly-typed version needed a test for exactly that, and a missing entry silently produced an empty prefix, which is how `magenta` came to be undefined
|
||||
- Reset color with `\x1b[0m` after colored text
|
||||
- Bold uses `\x1b[1;35m` (magenta bold)
|
||||
@@ -113,7 +171,7 @@ front is the same two commands in a more useful order.
|
||||
- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows
|
||||
|
||||
### Code Organization
|
||||
- Colorization functions (`colorize_line`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting
|
||||
- Colorization functions (`colorize_ordered`, `colorize_bold`, `content_trim_colored`) handle markdown formatting. `colorize_line` is gone: it was a `pub` alias for `colorize_bold` with one caller, and the only thing it added was asking the terminal
|
||||
- `show` renders the Metadata section as a two column table via `render_metadata_table`, not line by line. Column width is measured on the raw field names in characters and padding is applied before anything is styled: measuring a coloured string counts its escapes towards its width. `paint()` is `color_text()` with the colour decision passed in, which is what lets a test render both ways in one process
|
||||
- The title is printed once, by `cmd_show`. `content_trim_colored` skips the `# ` heading in the file content
|
||||
- Rules under headings are measured on the displayed name in characters, never on the raw line or in bytes
|
||||
|
||||
Generated
+1
-1
@@ -1494,7 +1494,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.7.2"
|
||||
version = "0.11.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.7.2"
|
||||
version = "0.11.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -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 [path...]` | 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. Each path opens the first `.worklane` at or above it, the working directory by default. Several paths are monitored together, as a tab per project plus an `all` tab that merges them, with `tab` and `shift+tab` between them |
|
||||
| `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>` |
|
||||
@@ -13,9 +13,12 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
|
||||
| `worklane set <ticket>` | Replaces fields with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--priority`. At least one required. Changing the title renames the file, keeping the UUID |
|
||||
| `worklane append <ticket>` | Adds to a section with `--description`, `--acceptance`, `--plan`. At least one required. The description gains a paragraph; list items go on the end, steps numbered on from the last |
|
||||
| `worklane relate <ticket>` | Records an edge to another ticket with `--blocked-by`, `--regression-of` or `--relates-to`, each repeatable. At least one required. Only the ticket named is written; `show` derives the other end by scanning. `mv` refuses to move a ticket blocked by one that is not done, unless `-f` |
|
||||
| `worklane chown <user> <ticket>` | Sets the Owner field, the only command that writes it. Free text, checked against nothing. User first and ticket second, after Unix `chown` |
|
||||
| `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 |
|
||||
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
---
|
||||
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.
|
||||
|
||||
A move is also refused while the ticket is blocked by one that is not done yet, see
|
||||
[Relating tickets](#relating-tickets).
|
||||
|
||||
## 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."
|
||||
worklane chown alice 1b78a24 # hand the ticket to someone
|
||||
```
|
||||
|
||||
`set` replaces, `append` adds. Neither has `--owner` or `--status`: owner is `chown`'s
|
||||
and status is `mv`'s, so each field has exactly one writer. A field set to the value it
|
||||
already holds is reported unchanged and nothing is written.
|
||||
|
||||
`chown` takes the **user first and the ticket second**, after Unix `chown`, which is the
|
||||
one command here that does not start with the ticket. The user is free text and is
|
||||
checked against nothing. Swap the two and the call fails, because the username has to
|
||||
resolve as a ticket.
|
||||
|
||||
`worklane init` creates `.worklane/` with the four status directories, for a repo that
|
||||
has no board yet.
|
||||
|
||||
## Relating tickets
|
||||
|
||||
```
|
||||
worklane relate 1b78a24 --blocked-by 4179958 # this one waits on that one
|
||||
worklane relate 1b78a24 --regression-of 6d327df # this one broke that one's fix
|
||||
worklane relate 1b78a24 --relates-to 7bfb9fc # neighbours, no dependency
|
||||
```
|
||||
|
||||
One flag per kind, and each repeats. The ticket comes first and the flag says what it is
|
||||
to the target, so read the call as a sentence: `relate A --blocked-by B` means A waits
|
||||
on B. **Only one side is stored**, on the ticket you name, and `show` derives the other
|
||||
end for the ticket at the far side, so never record both directions.
|
||||
|
||||
`--blocked-by` is enforced: `mv` refuses to move a ticket while a ticket it is blocked by
|
||||
is not in `done`, whichever move it is, and names every open blocker. `-f` moves it
|
||||
anyway, beside the backward and skipping moves it already allows. The other two kinds are
|
||||
reference data and never refuse anything.
|
||||
|
||||
Recording a relation the ticket already holds reports no change. A ticket cannot relate
|
||||
to itself, and a target that later disappears shows as `_missing_` rather than silently
|
||||
going away.
|
||||
|
||||
## 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 record it with `relate <new> --regression-of <old>`. 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 record it with `relate <new> --relates-to <old>`
|
||||
rather than only mentioning the id in prose.
|
||||
|
||||
## 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.
|
||||
+126
-35
@@ -2,7 +2,7 @@ use clap::Parser;
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use crate::util::{PRIORITY_RANGE, priority_legend};
|
||||
use crate::util::{PRIORITY_RANGE, RelationKind, priority_legend};
|
||||
|
||||
/// clap wants a `&str` with a long enough lifetime, and the legend is built from
|
||||
/// the same ramp the listing uses rather than spelled out a second time.
|
||||
@@ -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())]
|
||||
@@ -141,8 +109,35 @@ pub enum Command {
|
||||
/// Add to a section of an existing ticket
|
||||
Append(AppendArgs),
|
||||
|
||||
/// Record a relation from one ticket to another
|
||||
Relate(RelateArgs),
|
||||
|
||||
/// Change the owner of a ticket
|
||||
///
|
||||
/// User first, ticket second, after Unix `chown`. That reverses the ticket-first
|
||||
/// order `mv`, `comment` and `show` use, deliberately: the name borrows the Unix
|
||||
/// association, so the argument order borrows it too.
|
||||
///
|
||||
/// A swap is caught by resolution rather than by a check of its own. Given
|
||||
/// `chown 641e3d5 alice` the second argument has to resolve as a ticket, and a bare
|
||||
/// username usually will not, so the call fails on its own. It is silently wrong
|
||||
/// only when both arguments resolve, which needs a ticket whose title matches the
|
||||
/// username.
|
||||
Chown {
|
||||
/// New owner. Free text, like `add --owner`, checked against nothing
|
||||
#[arg(value_parser = non_empty)]
|
||||
user: String,
|
||||
|
||||
/// Ticket UUID or title
|
||||
ticket: String,
|
||||
},
|
||||
|
||||
/// Open the board view
|
||||
Tui,
|
||||
Tui {
|
||||
/// Projects to monitor, each resolved to the first `.worklane` at or above it.
|
||||
/// Several are shown as tabs. Defaults to the working directory
|
||||
paths: Vec<std::path::PathBuf>,
|
||||
},
|
||||
|
||||
/// Tick an acceptance criterion
|
||||
Check(CheckArgs),
|
||||
@@ -163,6 +158,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
|
||||
@@ -236,6 +283,50 @@ pub struct AppendArgs {
|
||||
pub plan: Vec<String>,
|
||||
}
|
||||
|
||||
/// `relate` is the only writer of the Relations section, the way `chown` is the only
|
||||
/// writer of Owner. One flag per kind rather than a `--kind` value: the accepted kinds
|
||||
/// are then clap's business, an unknown one is a usage error, and a call reads as a
|
||||
/// sentence about the ticket it names.
|
||||
///
|
||||
/// Each flag repeats, so several relations of one kind land in a single call. The
|
||||
/// targets are ticket searches, resolved by the same three tiers every other ticket
|
||||
/// argument is, and stored as the target's uuid.
|
||||
#[derive(clap::Args)]
|
||||
#[command(group(
|
||||
clap::ArgGroup::new("relation_kinds")
|
||||
.required(true)
|
||||
.multiple(true)
|
||||
.args(["blocked_by", "regression_of", "relates_to"])
|
||||
))]
|
||||
pub struct RelateArgs {
|
||||
/// Ticket UUID or title
|
||||
pub ticket: String,
|
||||
|
||||
/// Ticket this one waits on. Its own moves are refused until the target is done
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub blocked_by: Vec<String>,
|
||||
|
||||
/// Ticket whose fix this one broke
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub regression_of: Vec<String>,
|
||||
|
||||
/// Ticket this one is merely related to. Symmetric, so it is recorded once
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub relates_to: Vec<String>,
|
||||
}
|
||||
|
||||
impl RelateArgs {
|
||||
/// The relations asked for, one entry per kind, so the handler walks a table
|
||||
/// instead of repeating itself three times.
|
||||
pub fn requested(&self) -> [(RelationKind, &[String]); 3] {
|
||||
[
|
||||
(RelationKind::BlockedBy, &self.blocked_by),
|
||||
(RelationKind::RegressionOf, &self.regression_of),
|
||||
(RelationKind::RelatesTo, &self.relates_to),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/// `check` and `uncheck` are separate commands rather than one verb with a flag,
|
||||
/// because the two read as opposites at the call site and neither needs the other's
|
||||
/// name to make sense.
|
||||
|
||||
+247
-52
@@ -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, RelateArgs, 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());
|
||||
|
||||
@@ -298,13 +302,16 @@ fn write_new_comment(comments_dir: &Path, stem: &str, content: &str) -> Result<S
|
||||
pub fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> {
|
||||
let (_status, title, content) = resolve_ticket(search, worklane_dir)?;
|
||||
let ticket_uuid = parse_ticket_field(&content, "ID");
|
||||
// Read before anything is printed, so a board that cannot be read fails instead of
|
||||
// half printing a ticket.
|
||||
let relations = relations_block(&content, worklane_dir, should_use_colors())?;
|
||||
|
||||
// The only title in the output: content_trim_colored used to print it a second
|
||||
// time from the file content. Green per the colour guideline, and the rule is
|
||||
// measured in characters so a non-ASCII title is not over-drawn.
|
||||
println!("{}", color_text(&title, Color::Green));
|
||||
println!("{}", "─".repeat(title.chars().count()));
|
||||
println!("\n{}", content_trim_colored(&content));
|
||||
println!("\n{}", content_trim_colored(&content, &relations));
|
||||
|
||||
if ticket_uuid != "_Not set_" {
|
||||
let comments_dir = worklane_dir.join("comments").join(&ticket_uuid);
|
||||
@@ -371,7 +378,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;
|
||||
}
|
||||
|
||||
@@ -430,6 +437,59 @@ fn move_ticket_file(
|
||||
})
|
||||
}
|
||||
|
||||
/// Refuse a move while a ticket it is `blocked by` is not done.
|
||||
///
|
||||
/// Every move, not only the one into committed: an open blocker is a reason not to
|
||||
/// start and a reason not to finish, and one rule is easier to hold than a table of
|
||||
/// which transitions care. Called before anything is written, so a refusal leaves no
|
||||
/// rename, no rewritten field and no half moved ticket.
|
||||
///
|
||||
/// A target the board does not have warns and allows the move. Refusing there would
|
||||
/// wedge the ticket behind a bookkeeping fault with no way out but `--force`, and a
|
||||
/// dangling uuid is not a dependency.
|
||||
fn check_blockers(worklane_dir: &Path, content: &str, title: &str) -> Result<()> {
|
||||
let blockers: Vec<Relation> = parse_relations(content, title)?
|
||||
.into_iter()
|
||||
.filter(|relation| relation.kind == RelationKind::BlockedBy)
|
||||
.collect();
|
||||
|
||||
if blockers.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let index = RelationIndex::load(worklane_dir)?;
|
||||
let mut open: Vec<String> = Vec::new();
|
||||
|
||||
for blocker in &blockers {
|
||||
match index.get(&blocker.target) {
|
||||
Some(target) if target.status == DONE => {}
|
||||
Some(target) => open.push(format!(
|
||||
" ({}) {} [{}]",
|
||||
color_text(short_id(&target.uuid), Color::Red),
|
||||
target.title,
|
||||
color_text(&target.status, Color::Orange),
|
||||
)),
|
||||
None => eprintln!(
|
||||
"Warning: ticket '{}' is blocked by {}, which is not on the board.",
|
||||
title,
|
||||
short_id(&blocker.target),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
if open.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Every open blocker, not the first: a ticket waiting on three of them is not
|
||||
// unblocked by clearing the one the message happened to name.
|
||||
Err(anyhow!(
|
||||
"Cannot move '{}' while it is blocked by:\n{}\nUse --force (-f) to move it anyway.",
|
||||
color_text(title, Color::Green),
|
||||
open.join("\n"),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -> Result<()> {
|
||||
let valid_statuses = ["backlog", "committed", "reviewing", "done"];
|
||||
let forward_order = ["backlog", "committed", "reviewing", "done"];
|
||||
@@ -471,11 +531,18 @@ 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(());
|
||||
}
|
||||
|
||||
// After the no-op above, so a ticket is never refused for a move it is not making,
|
||||
// and behind `force`, which is where the other two overrides of a rule the board
|
||||
// keeps true already live.
|
||||
if !force {
|
||||
check_blockers(&worklane_dir, &resolved, &title)?;
|
||||
}
|
||||
|
||||
let current_path = worklane_dir.join(¤t_status);
|
||||
let target_path = worklane_dir.join(target_status);
|
||||
|
||||
@@ -505,39 +572,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,
|
||||
@@ -720,6 +754,34 @@ pub fn cmd_set(args: &SetArgs, start: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Rewrite the Owner field, the only writer of it.
|
||||
///
|
||||
/// The user comes first at the call site, after Unix `chown`, and the reasoning for
|
||||
/// reversing the ticket-first order is on the `Chown` variant. A swapped call is left
|
||||
/// to resolution: nothing here inspects `user` to see whether it also names a ticket,
|
||||
/// since the check would only fire on the case resolution already refuses and would
|
||||
/// stay silent on the one it cannot, a ticket whose title is the username.
|
||||
///
|
||||
/// No-op detection compares the whole file, the way `set` does, so an owner set to the
|
||||
/// value it already holds is reported unchanged and nothing is written.
|
||||
pub fn cmd_chown(user: &str, ticket_id: &str, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let (status, title, original) = resolve_ticket(ticket_id, &worklane_dir)?;
|
||||
let uuid = parse_ticket_field(&original, "ID");
|
||||
|
||||
let content = set_metadata_field(&original, "Owner", user, &title)?;
|
||||
|
||||
if content == original {
|
||||
report(&[], &title, "Updated");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
save_ticket(&worklane_dir, &status, &uuid, &title, None, &content)?;
|
||||
|
||||
report(&["owner"], &title, "Updated");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_append(args: &AppendArgs, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let (status, title, original) = resolve_ticket(&args.ticket, &worklane_dir)?;
|
||||
@@ -751,6 +813,76 @@ pub fn cmd_append(args: &AppendArgs, start: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Record a relation from one ticket to another.
|
||||
///
|
||||
/// One side is written and the inverse is derived wherever it is shown. `blocked by`
|
||||
/// goes on the gated ticket rather than `blocks` on the blocker: the gated ticket is the
|
||||
/// one whose move is refused and whose author knows about the dependency. `relates to`
|
||||
/// is symmetric, so it is written once, on whichever end the caller ran it from.
|
||||
///
|
||||
/// The kinds are a flag each rather than a `--kind` value, so an unknown kind is a
|
||||
/// usage error at the door instead of a line written into the file and refused on the
|
||||
/// way back out.
|
||||
pub fn cmd_relate(args: &RelateArgs, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let (status, title, original) = resolve_ticket(&args.ticket, &worklane_dir)?;
|
||||
let uuid = parse_ticket_field(&original, "ID");
|
||||
let existing = parse_relations(&original, &title)?;
|
||||
|
||||
// Every target resolved and every refusal raised before a byte is written, so a
|
||||
// call naming one good ticket and one bad one records neither.
|
||||
let mut items: Vec<String> = Vec::new();
|
||||
let mut changed: Vec<&str> = Vec::new();
|
||||
|
||||
for (kind, targets) in args.requested() {
|
||||
for search in targets {
|
||||
let (_target_status, target_title, target) = resolve_ticket(search, &worklane_dir)?;
|
||||
let target_uuid = parse_ticket_field(&target, "ID");
|
||||
|
||||
if target_uuid.trim().is_empty() || is_unknown_value(&target_uuid) {
|
||||
return Err(anyhow!(
|
||||
"Ticket '{}' has no ID field, so nothing can point at it",
|
||||
target_title
|
||||
));
|
||||
}
|
||||
|
||||
if target_uuid == uuid {
|
||||
return Err(anyhow!(
|
||||
"A ticket cannot relate to itself, and '{}' is the ticket being edited",
|
||||
title
|
||||
));
|
||||
}
|
||||
|
||||
let relation = Relation {
|
||||
kind,
|
||||
target: target_uuid,
|
||||
};
|
||||
|
||||
// Already held, either in the file or earlier in this call. Recording it
|
||||
// twice would read as two dependencies on one ticket.
|
||||
if existing.contains(&relation) || items.contains(&relation.item()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.push(relation.item());
|
||||
if !changed.contains(&kind.label()) {
|
||||
changed.push(kind.label());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if items.is_empty() {
|
||||
report(&[], &title, "Recorded");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let content = append_section_body(&ensure_section(&original, &RELATIONS), &RELATIONS, &items)?;
|
||||
save_ticket(&worklane_dir, &status, &uuid, &title, None, &content)?;
|
||||
|
||||
report(&changed, &title, "Recorded");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Which criterion to act on, asked for when the caller did not say.
|
||||
///
|
||||
/// A terminal gets the list and a prompt. Anything else gets the same list as an
|
||||
@@ -868,3 +1000,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
@@ -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:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-26
@@ -3,6 +3,7 @@ use clap::Parser;
|
||||
|
||||
mod command;
|
||||
mod handlers;
|
||||
mod install;
|
||||
mod tui;
|
||||
mod util;
|
||||
|
||||
@@ -37,29 +38,12 @@ fn main() -> Result<()> {
|
||||
let start = std::env::current_dir()?;
|
||||
|
||||
match cli.command {
|
||||
// No subcommand opens the board, the way a bare `frig` does.
|
||||
None | Some(Command::Tui) => run_tui(&start),
|
||||
// No subcommand opens the board, the way a bare `frig` does, and with no path
|
||||
// it opens the board above the working directory.
|
||||
None => run_tui(&[], &start),
|
||||
Some(Command::Tui { paths }) => run_tui(&paths, &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)
|
||||
@@ -75,6 +59,8 @@ fn main() -> Result<()> {
|
||||
}) => cmd_mv(&ticket, &status, force, &start),
|
||||
Some(Command::Set(args)) => cmd_set(&args, &start),
|
||||
Some(Command::Append(args)) => cmd_append(&args, &start),
|
||||
Some(Command::Relate(args)) => cmd_relate(&args, &start),
|
||||
Some(Command::Chown { user, ticket }) => cmd_chown(&user, &ticket, &start),
|
||||
Some(Command::Check(args)) => cmd_check(&args, true, &start),
|
||||
Some(Command::Uncheck(args)) => cmd_check(&args, false, &start),
|
||||
Some(Command::Comment {
|
||||
@@ -82,6 +68,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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,14 +96,14 @@ fn restore_terminal() -> std::io::Result<()> {
|
||||
)
|
||||
}
|
||||
|
||||
fn run_tui(start: &std::path::Path) -> Result<()> {
|
||||
fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()> {
|
||||
use crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers};
|
||||
use std::io::IsTerminal;
|
||||
|
||||
// The board is looked for before the terminal is, so running this outside a
|
||||
// The boards are looked for before the terminal is, so running this outside a
|
||||
// worklane directory gives the same message every other command gives rather than
|
||||
// a complaint about the terminal.
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let projects = tui::projects(paths, start)?;
|
||||
|
||||
// Without this, entering raw mode on a pipe fails with a bare "No such device or
|
||||
// address (os error 6)", which says nothing about the actual mistake. A bare
|
||||
@@ -128,7 +117,7 @@ fn run_tui(start: &std::path::Path) -> Result<()> {
|
||||
));
|
||||
}
|
||||
|
||||
let mut board = tui::Board::new(&worklane_dir)?;
|
||||
let mut board = tui::Board::new(projects)?;
|
||||
|
||||
install_panic_hook();
|
||||
crossterm::terminal::enable_raw_mode()?;
|
||||
@@ -176,6 +165,13 @@ 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),
|
||||
// Tabs cycle rather than clamp, the way tabs everywhere do, and are
|
||||
// a no-op with a single board. Free of every other binding: the
|
||||
// columns took hjkl and the arrows.
|
||||
KeyCode::Tab => board.select_tab(1, screen),
|
||||
KeyCode::BackTab => board.select_tab(-1, screen),
|
||||
// Free of the other bindings, and the footer names it in both states.
|
||||
KeyCode::Char('d') => board.toggle_done(screen),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+1705
-205
File diff suppressed because it is too large
Load Diff
+903
-75
File diff suppressed because it is too large
Load Diff
+21
-21
@@ -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
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
const UUID: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
/// 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: &Path) {
|
||||
fs::write(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join(format!("{}_original-title.md", UUID)),
|
||||
format!(
|
||||
"# Original title\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
The **Owner**: line quoted here is prose, not metadata.\n\
|
||||
\n\
|
||||
## Acceptance Criteria\n\
|
||||
- [x] Crit one\n\
|
||||
- [ ] Crit two\n\
|
||||
\n\
|
||||
## Implementation Plan\n\
|
||||
1. Step one\n\
|
||||
\n\
|
||||
## Notes\n\
|
||||
A handwritten note the tool knows nothing about.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {}\n\
|
||||
- **Priority**: 3\n\
|
||||
- **Tags**: alpha\n\
|
||||
- **Due**: 2026-09-01\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n\
|
||||
- **Status**: backlog\n",
|
||||
UUID
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path) -> String {
|
||||
let entry = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.find(|e| e.file_name().to_string_lossy().ends_with(".md"))
|
||||
.expect("no ticket file");
|
||||
fs::read_to_string(entry.path()).unwrap()
|
||||
}
|
||||
|
||||
fn stray_files(worklane: &Path) -> Vec<String> {
|
||||
fs::read_dir(worklane)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.filter(|name| {
|
||||
!["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chown_sets_the_owner() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "bob", UUID]);
|
||||
assert!(
|
||||
out.status.success(),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stdout).contains("owner"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- **Owner**: bob"), "{content}");
|
||||
|
||||
// Every other field is left as it was
|
||||
assert!(content.contains("- **Priority**: 3"), "{content}");
|
||||
assert!(content.contains("- **Tags**: alpha"), "{content}");
|
||||
assert!(content.contains("- **Due**: 2026-09-01"), "{content}");
|
||||
assert!(content.contains("- **Status**: backlog"), "{content}");
|
||||
}
|
||||
|
||||
/// The value is free text, matching `add --owner`, and is checked against nothing:
|
||||
/// not git, not a list of users.
|
||||
#[test]
|
||||
fn chown_accepts_any_user_without_validating_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "Nobody At All", UUID]);
|
||||
|
||||
assert!(
|
||||
ticket(&worklane).contains("- **Owner**: Nobody At All"),
|
||||
"{}",
|
||||
ticket(&worklane)
|
||||
);
|
||||
}
|
||||
|
||||
/// The tick and the unknown section are what a regenerated file would lose, and the
|
||||
/// quoted `**Owner**:` line in the description is what an unscoped rewrite would take
|
||||
/// instead of the real field.
|
||||
#[test]
|
||||
fn chown_leaves_everything_it_was_not_asked_about_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "bob", UUID]);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(
|
||||
content.contains("- [x] Crit one"),
|
||||
"the tick was lost: {content}"
|
||||
);
|
||||
assert!(
|
||||
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
|
||||
"the unknown section was lost: {content}"
|
||||
);
|
||||
assert!(
|
||||
content.contains("The **Owner**: line quoted here is prose, not metadata.\n"),
|
||||
"the prose was rewritten as metadata: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chown_reports_no_change_and_leaves_the_file_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "alice", UUID]);
|
||||
assert!(out.status.success());
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stdout).contains("No changes"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
|
||||
}
|
||||
|
||||
/// Resolution is `resolve_ticket`, the same as `mv` and `comment`, so all three tiers
|
||||
/// reach the ticket. The filename search reaches the middle of the uuid, which the
|
||||
/// prefix tier cannot.
|
||||
#[test]
|
||||
fn chown_resolves_a_uuid_prefix_a_title_or_a_filename() {
|
||||
for search in ["641e", "Original", "4d2f"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "bob", search]);
|
||||
assert!(
|
||||
out.status.success(),
|
||||
"{search} did not resolve: {:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(
|
||||
ticket(&worklane).contains("- **Owner**: bob"),
|
||||
"{search}: {}",
|
||||
ticket(&worklane)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The swap is left to resolution rather than checked for: the username has to resolve
|
||||
/// as a ticket, and a bare one does not.
|
||||
#[test]
|
||||
fn chown_refuses_a_swapped_call() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", UUID, "bob"]);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("No ticket found matching 'bob'"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// An empty user looks like a way to clear the field, and clearing is not supported.
|
||||
#[test]
|
||||
fn chown_refuses_an_empty_user_as_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "", UUID]);
|
||||
assert_eq!(out.status.code(), Some(2));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("clearing a field is not supported"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// A hand-made ticket without the field is refused rather than guessed at, the same
|
||||
/// as every other metadata field.
|
||||
#[test]
|
||||
fn chown_refuses_a_ticket_with_no_owner_field() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
fs::write(
|
||||
worklane.join("backlog").join(format!("{}_bare.md", UUID)),
|
||||
format!("# Bare\n\n## Metadata\n\n- **ID**: {}\n", UUID),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let out = run(&temp, &["chown", "bob", UUID]);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("has no Owner field"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
/// The staged temp file is renamed into place, so a completed write leaves nothing to
|
||||
/// be read as a stray ticket.
|
||||
#[test]
|
||||
fn chown_leaves_nothing_behind() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "bob", UUID]);
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// The file keeps its name: the slug follows the title, and the owner is not in it.
|
||||
#[test]
|
||||
fn chown_does_not_rename_the_file() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "bob", UUID]);
|
||||
|
||||
let names: Vec<String> = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.collect();
|
||||
assert_eq!(names, vec![format!("{}_original-title.md", UUID)]);
|
||||
}
|
||||
+16
-16
@@ -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();
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
+256
-18
@@ -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();
|
||||
@@ -640,3 +645,236 @@ fn mv_moves_the_resolved_ticket_when_two_share_a_title() {
|
||||
vec!["11111111-aaaa-bbbb-cccc-dddddddddddd_foo.md".to_string()]
|
||||
);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------- blocked by --
|
||||
|
||||
/// A ticket waiting on another, and a second one for it to wait on. Returns the
|
||||
/// filename of the gated ticket, whose relations the moves are then checked against.
|
||||
fn create_gated_pair(worklane: &std::path::Path, temp: &TempDir, status: &str) -> String {
|
||||
let filename = create_ticket(
|
||||
worklane,
|
||||
status,
|
||||
"Gated Task",
|
||||
"Waits on the blocker.",
|
||||
"aaaa1111aaaa1111aaaa1111aaaa1111aaaa",
|
||||
"alice",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
create_ticket(
|
||||
worklane,
|
||||
"backlog",
|
||||
"The Blocker",
|
||||
"Nothing waits on this.",
|
||||
"bbbb2222bbbb2222bbbb2222bbbb2222bbbb",
|
||||
"bob",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
|
||||
// Through the command, so the fixture cannot store a relation in a shape the tool
|
||||
// does not actually write.
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(temp.path())
|
||||
.args(["relate", "aaaa1111", "--blocked-by", "bbbb2222"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
filename
|
||||
}
|
||||
|
||||
fn move_ticket(temp: &TempDir, ticket: &str, status: &str, force: bool) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["mv", ticket, "--status", status]);
|
||||
if force {
|
||||
cmd.arg("-f");
|
||||
}
|
||||
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
/// Refused, and nothing written: not the rename, not the Status field, not a stray
|
||||
/// temp file. The blocker is named with its status, since that is what has to change.
|
||||
#[test]
|
||||
fn mv_refuses_a_move_while_a_blocker_is_open() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
let before = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(!out.status.success());
|
||||
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(stderr.contains("blocked by"), "{stderr}");
|
||||
assert!(stderr.contains("The Blocker"), "{stderr}");
|
||||
assert!(stderr.contains("backlog"), "{stderr}");
|
||||
assert!(stderr.contains("--force"), "{stderr}");
|
||||
|
||||
assert!(worklane.join("backlog").join(&filename).exists());
|
||||
assert_eq!(md_files(&worklane.join("committed")).len(), 0);
|
||||
assert_eq!(
|
||||
fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap(),
|
||||
before,
|
||||
"a refused move rewrote the ticket"
|
||||
);
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// Every open blocker, not the first: clearing the one the message happened to name
|
||||
/// would leave the ticket blocked and the reader surprised.
|
||||
#[test]
|
||||
fn mv_names_every_open_blocker() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_gated_pair(&worklane, &temp, "backlog");
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"reviewing",
|
||||
"The Second Blocker",
|
||||
"Also not done.",
|
||||
"cccc3333cccc3333cccc3333cccc3333cccc",
|
||||
"bob",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(temp.path())
|
||||
.args(["relate", "aaaa1111", "--blocked-by", "cccc3333"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(stderr.contains("The Blocker"), "{stderr}");
|
||||
assert!(stderr.contains("The Second Blocker"), "{stderr}");
|
||||
}
|
||||
|
||||
/// `-f` is where the deliberate overrides live, beside the backward and skipping moves.
|
||||
#[test]
|
||||
fn mv_moves_a_blocked_ticket_with_force() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", true);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mv_allows_the_move_once_the_blocker_is_done() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
|
||||
for status in ["committed", "reviewing", "done"] {
|
||||
assert!(
|
||||
move_ticket(&temp, "bbbb2222", status, false).status.success(),
|
||||
"the blocker itself could not be moved to {status}"
|
||||
);
|
||||
}
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// Every move, not only the one into committed. An open blocker is a reason not to
|
||||
/// finish as much as a reason not to start.
|
||||
#[test]
|
||||
fn mv_checks_the_blockers_on_every_move() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "reviewing");
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "done", false);
|
||||
assert!(!out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("reviewing").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// A move to the status the ticket is already in is not a move, so it is reported the
|
||||
/// way it always was rather than refused.
|
||||
#[test]
|
||||
fn mv_does_not_check_the_blockers_on_a_no_op() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_gated_pair(&worklane, &temp, "backlog");
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "backlog", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(String::from_utf8_lossy(&out.stdout).contains("already in"));
|
||||
}
|
||||
|
||||
/// A dangling target is a bookkeeping fault, not a dependency. Refusing there would
|
||||
/// wedge the ticket with no way out but `--force`.
|
||||
#[test]
|
||||
fn mv_warns_and_allows_when_a_blocker_is_not_on_the_board() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
fs::remove_file(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join("bbbb2222bbbb2222bbbb2222bbbb2222bbbb_the-blocker.md"),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("not on the board"),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// Only `blocked by` gates a move. The other two kinds are reference data.
|
||||
#[test]
|
||||
fn mv_ignores_the_kinds_that_are_not_blockers() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Related Task",
|
||||
"Points at an open ticket.",
|
||||
"aaaa1111aaaa1111aaaa1111aaaa1111aaaa",
|
||||
"alice",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"The Other",
|
||||
"Still open.",
|
||||
"bbbb2222bbbb2222bbbb2222bbbb2222bbbb",
|
||||
"bob",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(temp.path())
|
||||
.args([
|
||||
"relate",
|
||||
"aaaa1111",
|
||||
"--regression-of",
|
||||
"bbbb2222",
|
||||
"--relates-to",
|
||||
"bbbb2222",
|
||||
])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
/// The ticket under edit, the one it points at, and one that is already done.
|
||||
const GATED: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
|
||||
const BLOCKER: &str = "b1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d";
|
||||
const FIXED: &str = "f1f2f3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn slug(title: &str) -> String {
|
||||
title
|
||||
.to_lowercase()
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric() || *c == ' ' || *c == '-' || *c == '_')
|
||||
.map(|c| if c == ' ' { '-' } else { c })
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A ticket with a ticked criterion and a section the tool knows nothing about, so
|
||||
/// every test can check that recording a relation leaves both exactly as they were.
|
||||
fn create_ticket(worklane: &Path, status: &str, title: &str, uuid: &str) -> PathBuf {
|
||||
let path = worklane
|
||||
.join(status)
|
||||
.join(format!("{}_{}.md", uuid, slug(title)));
|
||||
|
||||
fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"# {}\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
Prose.\n\
|
||||
\n\
|
||||
## Acceptance Criteria\n\
|
||||
- [x] Crit one\n\
|
||||
\n\
|
||||
## Implementation Plan\n\
|
||||
1. Step one\n\
|
||||
\n\
|
||||
## Notes\n\
|
||||
A handwritten note the tool knows nothing about.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {}\n\
|
||||
- **Priority**: 3\n\
|
||||
- **Tags**: alpha\n\
|
||||
- **Due**: _Not set_\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n\
|
||||
- **Status**: {}\n",
|
||||
title, uuid, status
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
/// The three tickets every test starts from: the one being edited, one it can wait on,
|
||||
/// and one in done.
|
||||
fn board(temp: &TempDir) -> PathBuf {
|
||||
let worklane = setup_worklane(temp);
|
||||
create_ticket(&worklane, "backlog", "The gated one", GATED);
|
||||
create_ticket(&worklane, "backlog", "The blocker", BLOCKER);
|
||||
create_ticket(&worklane, "done", "The old fix", FIXED);
|
||||
worklane
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn stdout(out: &std::process::Output) -> String {
|
||||
String::from_utf8_lossy(&out.stdout).to_string()
|
||||
}
|
||||
|
||||
fn find(worklane: &Path, uuid: &str) -> PathBuf {
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
let dir = worklane.join(status);
|
||||
for entry in fs::read_dir(&dir).unwrap().filter_map(|e| e.ok()) {
|
||||
if entry.file_name().to_string_lossy().starts_with(uuid) {
|
||||
return entry.path();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
panic!("no file for ticket {uuid}");
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path, uuid: &str) -> String {
|
||||
fs::read_to_string(find(worklane, uuid)).unwrap()
|
||||
}
|
||||
|
||||
/// All three tiers, since the target is a ticket argument like any other: a uuid
|
||||
/// prefix, a title substring, and a substring reaching the middle of the filename.
|
||||
#[test]
|
||||
fn a_target_resolves_by_uuid_prefix_title_or_filename() {
|
||||
for search in ["b1b2", "blocker", "4a7b"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--blocked-by", search]);
|
||||
assert!(
|
||||
out.status.success(),
|
||||
"{search}: {}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(
|
||||
ticket(&worklane, GATED).contains(&format!("- blocked by {}", BLOCKER)),
|
||||
"{search}: {}",
|
||||
ticket(&worklane, GATED)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_kind_is_recorded_under_its_own_label() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"relate",
|
||||
GATED,
|
||||
"--blocked-by",
|
||||
BLOCKER,
|
||||
"--regression-of",
|
||||
FIXED,
|
||||
"--relates-to",
|
||||
"old fix",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success());
|
||||
|
||||
let content = ticket(&worklane, GATED);
|
||||
assert!(content.contains(&format!("- blocked by {}", BLOCKER)), "{content}");
|
||||
assert!(content.contains(&format!("- regression of {}", FIXED)), "{content}");
|
||||
assert!(content.contains(&format!("- relates to {}", FIXED)), "{content}");
|
||||
|
||||
// Each kind named once in the report, whatever the order of the flags.
|
||||
let reported = stdout(&out);
|
||||
for kind in ["blocked by", "regression of", "relates to"] {
|
||||
assert!(reported.contains(kind), "{reported}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The kinds are flags, so anything else never reaches the file: clap refuses it with
|
||||
/// a usage error, exit code 2, and nothing is written.
|
||||
#[test]
|
||||
fn an_unknown_kind_is_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, GATED);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--depends-on", BLOCKER]);
|
||||
assert_eq!(out.status.code(), Some(2), "{}", stdout(&out));
|
||||
assert_eq!(ticket(&worklane, GATED), before);
|
||||
}
|
||||
|
||||
/// A bare `relate <ticket>` is a usage error too, not a silent no-op, the same way a
|
||||
/// bare `set` and a bare `append` are.
|
||||
#[test]
|
||||
fn a_relate_with_no_kind_is_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
board(&temp);
|
||||
|
||||
assert_eq!(run(&temp, &["relate", GATED]).status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// Between the plan and the metadata, created for a ticket written before the section
|
||||
/// existed, and behind a handwritten section rather than in front of it.
|
||||
#[test]
|
||||
fn the_section_is_created_in_its_place() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
let content = ticket(&worklane, GATED);
|
||||
let at = |heading: &str| content.find(heading).unwrap_or_else(|| panic!("{heading}"));
|
||||
assert!(at("## Implementation Plan") < at("## Relations"), "{content}");
|
||||
assert!(at("## Notes") < at("## Relations"), "{content}");
|
||||
assert!(at("## Relations") < at("## Metadata"), "{content}");
|
||||
}
|
||||
|
||||
/// The full uuid, not the seven characters `ls` prints, which is what makes the link
|
||||
/// survive a rename of the target and stay unambiguous as the board grows.
|
||||
#[test]
|
||||
fn the_stored_target_is_the_full_uuid() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
assert!(
|
||||
ticket(&worklane, GATED).contains(&format!("- blocked by {}\n", BLOCKER)),
|
||||
"{}",
|
||||
ticket(&worklane, GATED)
|
||||
);
|
||||
|
||||
run(&temp, &["set", BLOCKER, "--title", "Renamed entirely"]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(shown.contains("Renamed entirely"), "{shown}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ticket_cannot_relate_to_itself() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, GATED);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--relates-to", "gated"]);
|
||||
assert!(!out.status.success());
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("cannot relate to itself"),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane, GATED), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_relation_already_held_reports_no_change_and_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
let before = ticket(&worklane, GATED);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
assert!(out.status.success());
|
||||
assert!(stdout(&out).contains("No changes"), "{}", stdout(&out));
|
||||
assert_eq!(
|
||||
ticket(&worklane, GATED),
|
||||
before,
|
||||
"the relation was recorded twice"
|
||||
);
|
||||
}
|
||||
|
||||
/// One direction is stored. The inverse is derived by a scan, so the ticket at the
|
||||
/// other end is not touched at all.
|
||||
#[test]
|
||||
fn only_the_ticket_named_is_written() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, BLOCKER);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
assert_eq!(ticket(&worklane, BLOCKER), before);
|
||||
assert!(!ticket(&worklane, BLOCKER).contains("Relations"));
|
||||
}
|
||||
|
||||
/// The tick, the handwritten section and the prose are what a regenerated file would
|
||||
/// lose, and the section is spliced in rather than rewritten around them.
|
||||
#[test]
|
||||
fn relate_leaves_everything_it_was_not_asked_about_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
let content = ticket(&worklane, GATED);
|
||||
assert!(content.contains("- [x] Crit one"), "the tick was lost: {content}");
|
||||
assert!(
|
||||
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
|
||||
"the unknown section was lost: {content}"
|
||||
);
|
||||
assert!(content.contains("1. Step one"), "{content}");
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
}
|
||||
|
||||
/// The kind, the short id and the title, so the section reads without a second lookup.
|
||||
#[test]
|
||||
fn show_renders_the_kind_the_short_id_and_the_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(shown.contains("Relations"), "{shown}");
|
||||
assert!(shown.contains("blocked by (b1b2c3d) The blocker"), "{shown}");
|
||||
// Never the stored line: a bare uuid says nothing about what it points at.
|
||||
assert!(!shown.contains(BLOCKER), "{shown}");
|
||||
}
|
||||
|
||||
/// Derived by scanning, since the file at this end holds nothing at all.
|
||||
#[test]
|
||||
fn show_lists_the_relation_the_other_ticket_holds() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
run(&temp, &["relate", GATED, "--relates-to", FIXED]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", BLOCKER]));
|
||||
assert!(shown.contains("blocks (641e3d5) The gated one"), "{shown}");
|
||||
assert!(!ticket(&worklane, BLOCKER).contains("Relations"));
|
||||
|
||||
// `relates to` is symmetric, so it reads the same way from either end.
|
||||
let shown = stdout(&run(&temp, &["show", FIXED]));
|
||||
assert!(shown.contains("relates to (641e3d5) The gated one"), "{shown}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_target_that_no_longer_exists_renders_as_missing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
fs::remove_file(find(&worklane, BLOCKER)).unwrap();
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(shown.contains("blocked by (b1b2c3d) _missing_"), "{shown}");
|
||||
}
|
||||
|
||||
/// The section is the one part of a ticket read back by machine, so a line nobody can
|
||||
/// parse is an error naming the ticket rather than a line quietly skipped.
|
||||
#[test]
|
||||
fn a_line_that_is_not_a_relation_is_an_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let path = find(&worklane, GATED);
|
||||
let content = fs::read_to_string(&path)
|
||||
.unwrap()
|
||||
.replace(
|
||||
"## Metadata",
|
||||
&format!("## Relations\n- depends on {}\n\n## Metadata", BLOCKER),
|
||||
);
|
||||
fs::write(&path, content).unwrap();
|
||||
|
||||
let out = run(&temp, &["show", GATED]);
|
||||
assert!(!out.status.success());
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(stderr.contains("is not a relation"), "{stderr}");
|
||||
assert!(stderr.contains("The gated one"), "{stderr}");
|
||||
}
|
||||
+6
-6
@@ -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
@@ -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
|
||||
|
||||
+69
-1
@@ -13,9 +13,23 @@ fn setup_worklane(temp: &TempDir) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A project inside the temp directory, for the path arguments. The temp directory
|
||||
/// itself is left without a board, so a path that resolves has to resolve to this one.
|
||||
fn setup_project(temp: &TempDir, name: &str) -> std::path::PathBuf {
|
||||
let project = temp.child(name);
|
||||
let worklane = project.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
project.path().to_path_buf()
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -69,6 +83,60 @@ fn an_unknown_subcommand_is_still_a_usage_error() {
|
||||
assert_eq!(run(&temp, &["--bogus"]).status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// A path argument is resolved before the terminal is, the same way the working
|
||||
/// directory is: reaching the tty complaint is what says the board was found.
|
||||
#[test]
|
||||
fn a_path_argument_names_the_board_to_open() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let project = setup_project(&temp, "project");
|
||||
|
||||
// Run from a directory with no board of its own, so only the argument can find one.
|
||||
let out = run(&temp, &["tui", project.to_str().unwrap()]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// And several of them, which is the point of taking paths at all.
|
||||
#[test]
|
||||
fn several_path_arguments_are_accepted() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let first = setup_project(&temp, "first");
|
||||
let second = setup_project(&temp, "second");
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&["tui", first.to_str().unwrap(), second.to_str().unwrap()],
|
||||
);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// With several paths, "No .worklane directory found" does not say which one was wrong.
|
||||
#[test]
|
||||
fn a_path_with_no_board_is_named_in_the_failure() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let project = setup_project(&temp, "project");
|
||||
|
||||
let elsewhere = temp.child("elsewhere");
|
||||
elsewhere.create_dir_all().unwrap();
|
||||
let path = elsewhere.path().to_str().unwrap().to_string();
|
||||
|
||||
// The first path resolves, the second does not.
|
||||
let out = run(&temp, &["tui", project.to_str().unwrap(), &path]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains(&path), "the failing path is not named: {stderr:?}");
|
||||
assert!(
|
||||
stderr.contains("No .worklane directory found"),
|
||||
"the usual message is gone: {stderr:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// `tui` has to appear in the help, or nothing points at it.
|
||||
#[test]
|
||||
fn the_help_lists_the_tui_command() {
|
||||
|
||||
Reference in New Issue
Block a user