(61879a4) Surface campaigns on the board, and bump to 0.20.0

A card label and a frame, not a campaign tab. A tab had to say what its
columns are, and a campaign groups across the flow rather than within one
status, so the answer is the four columns filtered: a filter on the board
it already has, not a fifth tab.

So a card names its campaign on the label row, before the tags, marked ~
and bold, and the row drops the tags whole before it drops the campaign.
`c` opens a picker; taking a campaign filters every column to its members
and draws a frame above them carrying the id, the codename, the name, the
opening line of the description and the standing. The standing comes from
the columns, since while a campaign is selected the columns are its
members. `q` takes off one layer at a time: the overlay, the filter, the
board.

The label needs something to say, which the stored uuid is not, so
campaigns gained `Codename`: one word, `v1` or `beaver`, written by
`campaign add --codename` and validated at parse time. `campaign ls`
prints it and `resolve_in` gained an exact-codename tier above the uuid
prefix, or it would be a field you can read and cannot type. Only
campaigns carry the field, so the tier is empty for a ticket and ticket
resolution is unchanged.

The campaigns index is read once per project in `columns_of`, on the pass
that already builds the cards, and `digest` now watches the campaigns
directory: without it a campaign filed elsewhere never reached the picker.
`frame_rows` grew a row, so the two bools deciding the geometry became one
`Chrome` and the row indices are named.

Left out and filed as d637288: nothing can give a codename to a campaign
that is already on the board.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-23 12:09:07 +02:00
co-authored by Claude Opus 5
parent c65e1b4ed7
commit 528566d103
13 changed files with 1945 additions and 104 deletions
+26 -3
View File
@@ -25,6 +25,7 @@
- The three stamps are `mv`'s, written by `set_status_stamp` from `Status::stamp_field`, and they are mutually exclusive: entering a status writes its field, leaving removes it, re-entering restamps. So a ticket carries at most one, the one for the status it is sitting in, and a backward move under `-f` leaves no stale `Completed On` behind. They are current state, like `Status` itself; the trail of how the ticket got there is d4ce964's job and must not be grown here. `backlog` has no stamp, `Created At` already answers for it
- Format: `**Field Name**: value`
- Ticket structure: `# Title` → `## Description` → `## Acceptance Criteria` → `## Implementation Plan` → `## Metadata`
- A **campaign** file carries `ID`, `Codename`, `Owner` and `Created At`, in that order, and no `Status`. `Codename` sits directly under the ID because that is what it is, a second way to say which campaign this is; it is written by `campaign add --codename` alone and is `_Not set_` when the flag was not given. It is not in `METADATA_ORDER`, which is the anchor list for the *upsert* on a ticket, and nothing upserts a campaign
- Comments stored in `.worklane/comments/<ticket_uuid>/<timestamp>.md` with `**Comment**`, `**Author**`, `**Time**` fields
## Status Workflow
@@ -41,6 +42,7 @@ and this file is for what someone changing worklane's own code needs.
- Tests use `assert_cmd` and `assert_fs` for CLI testing
- `setup_worklane()` creates temp `.worklane/` with all four status folders pre-created, plus `campaigns/` in `cmd_campaign.rs`, which is also where the on-demand creation is tested from a board without it
- `create_ticket()` writes fully-formed markdown files directly (no `--` separator for positional args in test commands)
- In `tui.rs`, `write_member_card` is `write_tagged_card` plus a Campaign field and `write_campaign` puts a campaign on disk, creating the campaigns directory as it goes — `board_dir()` deliberately does not, so every test that does not write one is also the test that a board with no campaigns draws. `picker_rows` cuts the picker's list out of the frame by its own geometry, for the reason `overlay_title_row` exists: a card carries the same campaign label, so a search over every row finds the board rather than the list
- **`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
- **`cargo fmt --check` is clean too, and `rustfmt.toml` is what makes that affordable.** rustfmt is the formatter here, run it. The config is four stable width settings and nothing else:
@@ -74,6 +76,7 @@ and this file is for what someone changing worklane's own code needs.
- **The shape is checked before chrono is asked.** `%Y-%m-%d` accepts an unpadded `2026-8-9`, which would be stored exactly as typed and sort before `2026-10-01` in any string comparison. Checking the length and the two dashes first is what lets a valid date be stored unchanged instead of normalised on the way in, which is the difference between validating and rewriting
- **Strict on the way in, tolerant on the way out.** `util::due_date` still cuts `2026-12-31T09:30:00Z` down to its date. A file written before the parser existed, or by hand, can hold one and still has to render; refusing to display what is already stored would punish the reader for the writer's mistake
- An empty `--due` keeps the clearing message rather than the date message. Somebody typing it is reaching for a way to clear the field, and the useful answer is the flag that does it
- **`campaign add --codename` is validated at parse time by `codename`**, which is `non_empty` plus one word. The board draws it as a label with a mark and no quoting, so `~beaver release` on that row reads as two labels and the second one is not a campaign; a title is where a sentence goes. Nothing else is checked: there is no registry of codenames, the same reason `ls --tag` refuses to validate a tag, and a length limit would be a number invented in the parser when the row that draws it already drops a label it cannot hold
- **There are two empty-value parsers, and which one an argument takes is the point.** `non_empty` says only that the value cannot be empty, for the arguments with no empty form: the `ls` filters, `relate`'s targets, and `set --title`, which addresses the ticket and names its file. `clearable` names `--clear`, for the arguments whose field does have one: `set --tags`, `--due` through `iso_date`, and the `chown` user. One message for both would either lie about `ls --tag` or leave the useful half unsaid. `add --due` takes the second one because `iso_date` is shared, and the answer it points at is a command later rather than the omission that would do it now, which is close enough to be worth the shared parser
- **A status is a `util::Status`, not a string.** `mv --status` and the `ls` positional take the value enum, so an unknown status is a usage error at parse time naming the four, exit 2, and no handler checks. That is the same bargain `--due` and `--priority` take, and it is what lets the shells complete the four for free. `Status::ALL` is the flow order, which `status_dirs()` and `cmd_mv` both read rather than spelling the names again, and `DONE` is defined from it
- The ticket positionals (`show <id>`, `mv <ticket>`, `comment <ticket>`) are also left alone, so a search term starting with a hyphen is a usage error. Reachable now that a hyphen-leading title can be stored: use the UUID, or put the flags first and separate with `--`, as in `mv --status committed -- -leading-title`
@@ -167,12 +170,14 @@ and this file is for what someone changing worklane's own code needs.
- **The full uuid is stored and the title is resolved for display**, as the Relations section already does. `reference_cell` is shared between the two, so a dangling campaign and a dangling relation target are both spelled `_missing_` rather than each inventing a spelling
- **`add` does not write the field.** Every ticket written before campaigns existed has none, so the insertion path has to exist regardless; leaving it out of `add` means one path that is always exercised rather than two. Same reasoning as the Relations section
- `set_or_insert_metadata_field()` is the upsert, and `METADATA_ORDER` is its anchor list, the way `SECTION_ORDER` is `ensure_section`'s. Campaign is placed before Status, so Status stays last where every file already keeps it. A file with no `## Metadata` heading is an **error, not an insertion**: per 641e3d5 such a file has no fields at all, and writing one above the prose would invent a shape nothing reads
- **The three tiers are `resolve_in()`, shared by tickets and campaigns.** A campaign is addressed exactly the way a ticket is, and a second resolver would be a second copy of the precedence rules to keep in step. `Found.dir` is the status for a ticket and empty for a campaign, which is what makes the ambiguity listing drop the bracket for one
- **The four tiers are `resolve_in()`, shared by tickets and campaigns.** A campaign is addressed exactly the way a ticket is, and a second resolver would be a second copy of the precedence rules to keep in step. `Found.dir` is the status for a ticket and empty for a campaign, which is what makes the ambiguity listing drop the bracket for one
- **An exact `Codename` is the top tier, and it lives in the shared resolver rather than in a campaign-only path.** Only campaigns carry the field, so `parse_codename` returns `None` for every ticket and the tier is always empty for one: ticket resolution is unchanged, which `a_ticket_search_is_unaffected_by_the_codename_tier` pins. It goes above the uuid prefix because it is an exact match on a field written for the purpose, where a substring can be a coincidence, and because a codename like `v1` is below `MIN_ID_SEARCH` and would never be tried as an id at all. A codename that a title also contains, `v2` against `v2 release`, has to win outright rather than be reported ambiguous against it
- **`resolve_ticket` explains a search that names a campaign**, rather than each command doing it. One place, so `mv`, `show`, `chown` and everything else that takes a ticket give the same reason instead of a bare "no ticket found". Checked only on the zero-match path, so it costs nothing normally, and only when exactly one campaign matches: an ambiguous ticket error must not be replaced by a complaint about a directory the caller never mentioned
- **`Resolved` carries what `content_trim` cannot render from the file.** The relations block and the campaign cell both come from elsewhere on the board. A struct rather than two more parameters, so the next such field is one entry here instead of an edit at every call site
- `campaign show` lists **done** members, unlike `ls`, which leaves the done column out of its listing. What is finished against what is left is the whole question a campaign asks, so hiding half the answer is not an option. `ls --campaign` is the other way round: it is the ordinary board filtered, and keeps every rule `ls` already has
- `campaign ls` scans the status directories **once per campaign** to count members. That is a scan per row rather than one walk reused, and it is deliberate: the map-from-uuid version is worth writing when a board has enough campaigns to notice
- **The TUI gets neither a campaign tab nor a card marker**, for now. The detail view resolves the field because it renders the body, and that is all. A marker on a card would want a campaigns read per reload, which is more than the blocked mark cost: that one reads the ticket's own Relations section on the pass that already builds the card, and a campaign title is in another directory
- **The TUI got a card label and a frame, not a campaign tab.** 61879a4 decided it. A tab would have had to answer what its columns are, and a campaign groups *across* the flow rather than within one status, so the honest answer is the four statuses filtered — which is a filter on the board it already has rather than a fifth tab. So: a label on the card, a frame above the columns while one is selected, and `c` for the picker. The cost the earlier decision balked at, a campaigns read per reload, is paid once per project in `columns_of` and is what names the label; see The Board View
- **A campaign is named by its codename on the board, and by its short id when it has none.** The uuid does not fit on a card and the title is a sentence, which is the gap `Codename` fills. `campaign_label` builds it in one place, as a `Cell`, so the CLI paints it and the board makes a span of it; the mark is `CAMPAIGN_MARK`, `~`, beside `#` for a tag
- `campaign_body()` builds the file from `DESCRIPTION` and `METADATA_HEADING` rather than its own string literals, so the two file formats cannot drift apart on the spelling of a heading. A campaign has no acceptance criteria (its definition of done is derived), no implementation plan and no Status
- The campaigns directory is created by `init` and **on demand** by `campaign add`, since every board made before campaigns existed has none and a `worklane init` over a live board to get one would be a strange thing to have to do
@@ -212,6 +217,21 @@ and this file is for what someone changing worklane's own code needs.
- **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
- **A card names its campaign on the label row, before the tags, in bold.** `labels_line` draws both, `CAMPAIGN_MARK` (`~`) for the campaign and `#` for a tag, and the campaign takes the row's width first: two cards in one campaign is what a reader looking for a campaign is looking for, and the tags are the context around it. So a row too narrow for both drops the tags whole and keeps the campaign, the order `corner_line` and `project_label` already follow, and a campaign the row will not hold at all goes whole too. A ticket in neither spends no row, so **a ticket in no campaign renders exactly as it did before campaigns reached the card**
- **`Card::campaign` is a resolved `Cell`, not a uuid**, settled at reload the way `project` and `blocked` are. `TicketItem::campaign` already carries the uuid off the pass that builds the card; the name is in another directory, so `columns_of` reads `CampaignIndex` once per project and hands it to every card. Never per draw, the rule `criteria` and `tags` already hold. The merge carries the resolved cell rather than looking it up again, for the reason it carries `blocked`: a campaign is addressed inside one `.worklane`, so a merged lookup could answer one project's uuid with another project's campaign
- **A campaign the board does not hold labels nothing**, the answer `mark_blocked` gives a dangling blocker. `campaign_cell` renders that case as `_missing_` because a metadata table is a place to report a dangling reference; a card is not
- **`c` opens the campaign picker, and taking a campaign filters the tab's columns to its members.** Not a fifth tab: a campaign groups across the flow, so the shape of the answer is the four statuses with fewer cards in them, which is what `campaign show` already answers the question in. Every column is kept, empty ones included. The filter is applied in `reload`, where the columns are built, so nothing downstream has to ask whether a campaign is selected — the board simply holds fewer cards, and `first_match`, `done_count` and the copy key all keep working unchanged
- **`Tab::campaign` is a uuid on the tab, not on the `Board`.** A campaign belongs to one `.worklane`, so a filter carried onto another project's tab would empty it and say nothing about why. It is looked up by uuid rather than held as an index, and a selection whose campaign has left the board is cleared by `reload` rather than left filtering the board to nothing
- **The frame above the columns is three rows, and `Chrome` is what every measurement takes.** `frame_rows` grew a row, so the two bools that decide the geometry became one `Chrome`, copied from `Board::chrome`: adjacent same-typed parameters are what the Rust Style rule warns about, and the draw and `follow_selection` have to measure one answer or a keypress scrolls against a board the next frame does not draw. The row indices are named (`TAB_ROW`, `CAMPAIGN_ROW`, `BOARD_ROW`, `FOOTER_ROW`), since an index written out by hand goes on meaning what it used to
- **The frame says the rest of what it has to say on its borders**, the trade the detail overlay makes with its title and its page indicator: `(id) ~codename · Name` on the top one, the standing on the bottom right, and `q board` on the bottom left. One text row, the opening line of the description. Every row spent here is a row of cards
- **The standing comes from the columns, not from a walk of the tree.** While a campaign is selected the columns *are* its members, done included, so `Tab::standing` counts what is already in hand rather than paying what `campaign ls` pays per campaign. Counted over every column, drawn or not: hiding done is a change to what is drawn and never to what is counted
- **The way out is on the frame's own border, not in the footer.** `q board` sits on the thing it takes away, and the footer row was already at its width naming eight keys. Dropped whole when it and the standing would meet, the rule the page indicator follows
- **`c` is named in the footer only on a closed board with nothing selected**, which is where a reader has to find it. Over an open ticket and on a filtered board it is left out: the frame's border then says how to put the campaign away, and the row has no cells to spare. Incomplete rather than wrong, which is the trade this row is allowed to make — what it must never do is name a key by what it used to do
- **`picker: Option<Picker>` is the whole mode**, the shape `search` and `detail` use, and `Board::picker_key` runs beside `search_key` ahead of the action arms for the same reason: an open list owns the keyboard, so `d` must not toggle done and `q` must not quit while a campaign is being chosen. `ctrl-c` is the one key it declines and every other control combination is swallowed, or `ctrl-d` would reach the arm bound to `d`
- **The picker's rows are `Tab::campaigns`, not a copy taken when it opened**, so a campaign filed elsewhere appears in an open picker on the next tick. It opens on the campaign already selected, so `c` on a filtered board says where you are as well as offering somewhere to go, and a board with no campaigns gets a `Notice` rather than an empty box that has to be dismissed to learn it was empty
- **A picker row draws a real codename only.** The row opens with the short id, so the card's `~<id>` fallback would print it twice and say nothing the second time
- **`q` takes off one layer at a time, in the order they were put on**: the overlay, then the campaign filter, then the board. `Board::dismiss` holds all three, and it takes the screen now because clearing the filter reloads and has to follow the selection. Selecting a campaign closes an open ticket, the answer hiding the done column already gives: the ticket may not be on the filtered board at all, and swapping it for a different one without saying so is how a person acts on the wrong ticket
- **`digest` watches the campaigns directory** as well as the statuses and the comments. A campaign filed elsewhere has to reach the picker and a codename edited by hand has to reach every card that names it, and a directory's own mtime would miss the edit
- **The tags go under the title, dimmed, each prefixed with `#`.** The field was invisible on the board: nothing said a ticket was tagged `bug` without opening it. The marker is what stops the row reading as a third line of the title, since a tag is an ordinary word and the title sits directly above it. The row is dropped whole when the column will not hold it, the rule a corner follows, and an untagged ticket spends no row at all, the way a short title spends no second one
- `tags` is a field on `TicketItem`, filled in `collect_ticket_items` through `parse_tags`, for the reason the criteria count is. `parse_tags` splits the comma-separated field into whole trimmed values, so a caller asking for `bug` is not answered by `bugfix`, and reads absent, `_None_` and empty as the same answer
- **A held-up card carries `BLOCKED_MARK`, `×`, after its id, in brightred.** The constant lives in `util.rs` and the relations block draws the same one, since both say the same word. A ticket waiting on an open blocker looked exactly like one that is ready, and the board is where the next thing to pick up is chosen. Not a fourth circle from Geometric Shapes: those belong to the priority meter two cells away and would read as part of that ramp. The multiplication sign is Latin-1, like the middle dot the unset priority draws, so it renders wherever the meter does
@@ -331,6 +351,8 @@ and this file is for what someone changing worklane's own code needs.
- Relation kind mark → brightred `×` blocked by and blocks, cyan `→` relates to, orange `←` regression of and regressed by. A small ramp inside one column, the way the priority meter is: the mark says which kind of edge the row is, so none of these three is a colour standing in for the uuid or the title beside it. Brightred on the cross rather than red, because the id one cell to its right is red and the two would blend. It is the colour and the glyph a held-up card already carries, which is the point: one vocabulary for blocking
- Relation status mark → grey `○` backlog, orange `◐` committed, cyan `◐` reviewing, green `●` done, grey `?` for a target the board does not hold. The second ramp in that column: the shape says how far the target has got and the colour tells the two middle stages apart, since both are half circles. **Green is here and deliberately absent from the priority ramp**, where it would sit on a whole line and read as a title; on a one-cell mark with no title behind it, it is the obvious colour for finished and nothing else wants it. Orange keeps the meaning it already has, Status, and grey keeps unset for the one row with no status to show
- Chrome → grey. The footer's key names, a rendered `[ ]`, and the overlay's page indicator. Not a new slot: grey already means "what a reader skips", which is the other half of the unset-value meaning, and none of these is a value. The indicator in orange would read as the title it faces across the overlay, in cyan as a timestamp, and in the priority ramp's colours as a level
- Campaign label → its codename through `tag_color`, bold, marked `~`. The colour is what groups a campaign across the cards that carry it, which is exactly what a tag's colour is for, and one word is one colour in every view because `tag_color` is a pure function of it. The mark and the bold are what tell it from a tag on a row that holds both: the mark is not `#`, or the row would read as a list of tags with a stranger in it, and not `@`, which reads as a person on every board anyone has used. `Codename` in a metadata table takes the colour without the mark, since the field name has already said what it is
- Campaign label with no codename → grey. The label is then the short id, and grey keeps a reserved meaning off a `TAG_COLORS` slot in the one case where it would land on one: red is the uuid's everywhere else, and grey already means what a reader skips, which is what a campaign with no codename has to say for itself
- **The palette splits in two: seven colours that each mean one thing, and `TAG_COLORS`, the eight a tag may be drawn in.** A tag in red would read as a uuid, in green as a title, in grey as an unset value, so the tag slots are reserved as a list rather than picked at the call site. Do not assign a new meaning to a colour in `TAG_COLORS`, and do not draw a tag in one outside it
- `tag_color()` is a pure function of the tag string, so the same tag is the same colour on every card, in every view and on every board, with nothing stored. Case sensitive, because `Bug` and `bug` are two different tags to the field and to every search
- **The hash is FNV-1a written out here, not `DefaultHasher`.** std does not promise its output is stable across releases, and a board that repaints itself on a toolchain upgrade has lost the only property the mapping is for. `the_tag_mapping_is_pinned` fails on any change to it, so a repaint is a decision rather than a surprise
@@ -350,7 +372,8 @@ and this file is for what someone changing worklane's own code needs.
### Ticket Resolution
- `resolve_ticket()` returns `(status, title, content)` tuple
- Three tiers, evaluated in order: UUID prefix > title substring > filename substring. The first non-empty tier wins outright and later tiers are not consulted. This is not cosmetic: ticket titles reference other tickets by id, so a flat OR of the three reported an exact prefix match as ambiguous against whichever title mentioned it
- Four tiers, evaluated in order: exact codename > UUID prefix > title substring > filename substring. The first non-empty tier wins outright and later tiers are not consulted. This is not cosmetic: ticket titles reference other tickets by id, so a flat OR of the tiers reported an exact prefix match as ambiguous against whichever title mentioned it
- The codename tier is a campaign's, and empty for a ticket, which has no such field. Case insensitive like the other three, so a codename typed back off a listing resolves whatever case it was read in. See Campaigns for why it sits above the uuid prefix
- The UUID tier applies from `MIN_ID_SEARCH` (4) characters up. Not 8: `ls` prints `SHORT_ID_WIDTH` (7) characters, so a longer minimum would drop the printed id out of the UUID tier and let any title quoting it win instead. Below the minimum the search is text, so `show 641` is a title search
- The filename tier earns its place by reaching the middle of a UUID, which the prefix tier cannot. It is also why a short UUID search still resolves under a longer minimum, just at the wrong precedence, so a test for the minimum needs a decoy title to be meaningful
- Ambiguous matches (multiple results) print options and exit(1)
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.19.0"
version = "0.20.0"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.19.0"
version = "0.20.0"
edition = "2024"
[dependencies]
+6 -2
View File
@@ -5,11 +5,11 @@ Worklane is a local Kanban flow for agentic software development.
## Commands
| Command | Description |
|---------|-------------|
| `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, whose border carries a page indicator while there is more of it than fits, `/` to jump to the first ticket whose id or title matches, `y` to copy the selected ticket's short id to the clipboard, `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` 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, whose border carries a page indicator while there is more of it than fits, `/` to jump to the first ticket whose id or title matches, `y` to copy the selected ticket's short id to the clipboard, `c` to pick a campaign and filter the columns to its members, `q` to close whatever is open and then to quit. A card carries its campaign beside its tags, marked `~` and bold; while one is selected a frame above the columns names it and says how far it has got, and `q` on its border gives the whole board back. 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. `--due` takes `YYYY-MM-DD` and refuses anything else at parse time |
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>`, `--tag <tag>` and `--campaign <campaign>`, which compose in any combination. `--tag` matches a whole value of the comma-separated Tags field, case sensitively, so `--tag bug` does not list a ticket tagged `bugfix` or one tagged `Bug`. `--ids` prints one ticket per line as its short id, a tab and its title, unstyled, done included, for a script or a completion |
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring |
| `worklane show <id>` | Shows ticket by UUID prefix (4+ chars), title substring, or filename substring. A campaign is addressed the same way, plus its exact codename, which wins over all three |
| `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. `--clear <field>` returns a field to unset instead, repeatable, taking `due`, `tags`, `priority`, `description`, `acceptance` or `plan`, and writing back exactly what `add` writes for a field it was never given. No `title`, which addresses the ticket, and no `owner`, which is `chown`'s. Replacing and clearing the same field in one call is refused |
| `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 |
@@ -18,6 +18,10 @@ Worklane is a local Kanban flow for agentic software development.
| `worklane check <ticket> [criteria...]` | Ticks acceptance criteria, each by number as shown by `show` or by a substring. Several in one call, or `all` for every one of them. Prompts with the numbered list if none is given, or errors with it when there is no terminal |
| `worklane uncheck <ticket> [criteria...]` | Unticks acceptance criteria, addressed the same way |
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
| `worklane campaign add` | Files a campaign in `.worklane/campaigns/` with `--title`, `--description`, `--codename` and `--owner`. A campaign has no status: its state is derived, open until every member is done. `--codename` is one word to call it by, `v1` or `beaver`, which is what the board draws on every card in it and what every command that takes a campaign will also resolve it by |
| `worklane campaign ls` | Lists the campaigns as their short id, their codename, their title and how many members are done. `--ids` prints one per line as the id, a tab and the title, unstyled, for a script or a completion |
| `worklane campaign show <campaign>` | Shows a campaign and its members grouped by status, done included, since what is finished against what is left is the question a campaign asks |
| `worklane assign <campaign> <ticket>` | Puts a ticket in a campaign, the only command that writes the Campaign field. Campaign first and ticket second, after `chown`. A ticket is in at most one, so assigning one that already belongs somewhere moves it |
| `worklane tags` | Lists the tags the board carries as the tag, a tab and how many tickets carry it, one per line, unstyled and alphabetical. Case sensitive like `ls --tag`, so `bug` and `Bug` list separately and land next to each other. Every status, done included. The one command that answers what tags exist rather than what carries a tag already known |
| `worklane completions <shell>` | Prints a completion script for `fish`, `bash`, `zsh`, `elvish` or `powershell`. See below |
| `worklane install-skill [skill]` | Writes the embedded agent skills to `~/.claude/skills/<skill>/SKILL.md`, which Claude Code and opencode both read. Three ship: `worklane` teaches the CLI, `worklane-review` reviews a finished ticket against the code that claims to close it, `worklane-plan` grooms the board as a whole, its priorities, due dates, tags and campaigns. Every document unless one is named. Leaves a modified copy alone unless `--force`; `--print` writes one to stdout instead and needs the name |
+8 -3
View File
@@ -158,9 +158,9 @@ fields; a goal is a campaign.
```
worklane campaign ls
worklane campaign show "v1 release"
worklane campaign add --title "..." --description "..."
worklane assign "v1 release" 1b78a24
worklane campaign show v1
worklane campaign add --title "..." --codename v1 --description "..."
worklane assign v1 1b78a24
```
A campaign is the tickets that have to be finished **together** for one outcome. The test
@@ -177,6 +177,11 @@ tui is usable on a narrow terminal" is a campaign. "The tui tickets" is a tag.
- **A campaign's state is derived**, open until every member is done. There is nothing to
close and nothing to move. A campaign whose members are all done is finished already.
- `assign` takes the **campaign first and the ticket second**, like `chown`.
- **Propose a codename with the campaign**, one word, `v1` or `beaver`. It is what the
board draws on every card in it and the shortest thing that addresses it at the command
line, and a campaign filed without one is drawn by its short id, which says nothing. A
campaign already on the board that has no codename is worth pointing out for the same
reason a near-duplicate tag is.
Proposing a campaign means naming the goal, the members, and what is deliberately left
out of it. The last part is what makes it a goal rather than a pile.
+15 -7
View File
@@ -206,15 +206,21 @@ status directory. Its state is derived instead, open until every member is done,
there is no such thing as a done campaign holding an open ticket.
```
worklane campaign add --title "v1 release" \
worklane campaign add --title "First public release" --codename v1 \
--description "Everything that has to ship before the tag."
worklane campaign ls # every campaign and how far it has got
worklane campaign ls # every campaign, its codename, how far it has got
worklane campaign ls --ids # id and title, tab separated, like ls --ids
worklane campaign show "v1 release" # its body, then its members by status
worklane assign "v1 release" 1b78a24 # put a ticket in it
worklane ls --campaign "v1 release" # only that campaign's tickets
worklane campaign show v1 # its body, then its members by status
worklane assign v1 1b78a24 # put a ticket in it
worklane ls --campaign v1 # only that campaign's tickets
```
**Give a campaign a `--codename`.** One word, `v1` or `beaver`. It is what the board
draws on every card in the campaign, because a uuid does not fit there and a title is a
sentence, and it is the shortest thing that addresses the campaign at the command line.
Optional: a campaign without one is drawn and listed by its short id instead, which
resolves but says nothing.
`assign` takes the **campaign first and the ticket second**, like `chown`, and is the
only writer of the field. `add` has no `--campaign` and neither has `set`, so membership
has one writer the way owner and status do.
@@ -227,8 +233,10 @@ reports no change and writes nothing.
its listing: a campaign is precisely the question of what is finished against what is
left.
A campaign is addressed the way a ticket is, by uuid prefix, title or filename, but it
is not a ticket. Passing one where a ticket is expected is refused with a message saying
A campaign is addressed the way a ticket is, by uuid prefix, title or filename, and by
its exact codename, which wins over all three. So `assign v1 1b78a24` reaches the
campaign codenamed `v1` even if another campaign's title contains `v1`. It is not a
ticket, though. Passing one where a ticket is expected is refused with a message saying
so, and there is no way to move a campaign, because it has no status to move.
## Search the backlog before filing
+24 -1
View File
@@ -41,6 +41,12 @@ pub fn ensure_campaigns_dir(worklane_dir: &Path) -> Result<PathBuf> {
pub struct Campaign {
pub uuid: String,
pub title: String,
/// The word the campaign is called by, or `None` for one filed without a codename.
///
/// Read here rather than parsed at each call site for the reason the title is: the
/// board draws it on every card that names this campaign, and the picker draws it on
/// every row, so it comes off the one read of the directory.
pub codename: Option<String>,
pub content: String,
}
@@ -80,6 +86,7 @@ pub fn resolve_campaign(search: &str, worklane_dir: &Path) -> Result<Campaign> {
}
Ok(Campaign {
codename: parse_codename(&found.content),
uuid,
title: found.title,
content: found.content,
@@ -103,6 +110,11 @@ pub fn campaign_named(search: &str, worklane_dir: &Path) -> Option<String> {
/// One pass for the same reason [`RelationIndex`] takes one: rendering a ticket's
/// Campaign field or listing the campaigns both need every one of them, and a lookup
/// per ticket would read the directory once per row.
///
/// `Default` is the empty index, which is what a board whose campaigns directory cannot be
/// read has: it still draws, with no campaign on any card. A *missing* directory is already
/// not an error, per [`CampaignIndex::load`]; this is for the unreadable one.
#[derive(Default)]
pub struct CampaignIndex {
campaigns: Vec<Campaign>,
}
@@ -130,6 +142,7 @@ impl CampaignIndex {
campaigns.push(Campaign {
uuid: parse_ticket_field(&content, "ID"),
title: heading_title(&content),
codename: parse_codename(&content),
content,
});
}
@@ -250,6 +263,9 @@ impl Standing {
/// The campaign file as it is written.
///
/// The codename sits directly under the ID, because that is what it is: a second way to
/// say which campaign this is, in a word rather than in thirty-six characters.
///
/// The same shape a ticket has, minus what a campaign has no use for: no acceptance
/// criteria, because its definition of done is derived from its members rather than
/// written down, no implementation plan, and no Status, because it sits in no status
@@ -258,6 +274,7 @@ impl Standing {
pub fn campaign_body(
title: &str,
description: &[String],
codename: Option<&str>,
id: &uuid::Uuid,
owner: Option<&str>,
created_at: &str,
@@ -279,11 +296,17 @@ pub fn campaign_body(
{metadata_heading}\n\
\n\
- **ID**: {id}\n\
- **{codename_field}**: {codename}\n\
- **Owner**: {owner}\n\
- **Created At**: {created_at}\n\
",
description_heading = DESCRIPTION.heading,
metadata_heading = METADATA_HEADING,
owner = owner.unwrap_or("_Not set_"),
codename_field = CODENAME_FIELD,
// Written unset rather than left out, the way `add` writes an unset Due on every
// ticket: the line is then there to read and there to edit by hand, and one shape
// of file is one thing for the parser to be right about.
codename = codename.unwrap_or(NOT_SET),
owner = owner.unwrap_or(NOT_SET),
)
}
+32
View File
@@ -109,6 +109,27 @@ fn iso_date(raw: &str) -> Result<String, String> {
Ok(raw.to_string())
}
/// Reject a codename that is not one word.
///
/// At parse time, like `iso_date` and `priority_level`, so a mistyped value is a usage
/// error with nothing written. One word because the board draws it as a label beside the
/// tags, with a mark and no quoting: `~beaver release` on that row reads as two labels, and
/// the second one is not a campaign. A title is where a sentence goes.
///
/// Nothing else is checked. There is no registry of codenames to check against, the same
/// reason `ls --tag` refuses to validate a tag, and a length limit would be a number
/// invented here: a label the column will not hold is dropped whole by the row that draws
/// it.
fn codename(raw: &str) -> Result<String, String> {
let value = non_empty(raw)?;
if value.split_whitespace().count() > 1 {
return Err("codename must be a single word, for example v1 or beaver".to_string());
}
Ok(value)
}
/// Arguments that carry prose, and therefore have to accept a value starting with
/// a hyphen.
///
@@ -299,6 +320,9 @@ pub enum CampaignCommand {
/// and no implementation plan. Priority, tags and a due date are left out because
/// nothing reads them yet, and a field written but never shown is a field that goes
/// stale unnoticed.
///
/// `--codename` is the exception to that last rule and earns it: the board draws it on
/// every card in the campaign, and it exists because the uuid does not fit there.
#[derive(clap::Args)]
pub struct CampaignAddArgs {
/// Campaign title
@@ -309,6 +333,14 @@ pub struct CampaignAddArgs {
#[arg(short, long, allow_hyphen_values = PROSE)]
pub description: Vec<String>,
/// A single word to call the campaign by, for example v1 or beaver
///
/// The uuid is what every command stores and the title is a sentence, so neither is
/// what a card has room to print. This is the short form the board draws, and it is
/// optional: a campaign without one is drawn by its short id instead.
#[arg(short, long, value_parser = codename)]
pub codename: Option<String>,
/// Owner. Defaults to the git user
#[arg(short, long)]
pub owner: Option<String>,
+21 -2
View File
@@ -1037,7 +1037,12 @@ pub fn cmd_relate(args: &RelateArgs, start: &Path) -> Result<()> {
/// half-written campaign behind. `cmd_add` predates that primitive and still uses the
/// plain write; the difference is noted on the ticket rather than fixed here.
pub fn cmd_campaign_add(args: &CampaignAddArgs, start: &Path) -> Result<()> {
let CampaignAddArgs { title, description, owner } = args;
let CampaignAddArgs {
title,
description,
codename,
owner,
} = args;
let worklane_dir = find_worklane_dir(start)?;
let dir = ensure_campaigns_dir(&worklane_dir)?;
@@ -1054,6 +1059,7 @@ pub fn cmd_campaign_add(args: &CampaignAddArgs, start: &Path) -> Result<()> {
let body = campaign_body(
title,
description,
codename.as_deref(),
&id,
owner.as_deref(),
&Local::now().format(TIMESTAMP_FORMAT).to_string(),
@@ -1099,9 +1105,22 @@ pub fn cmd_campaign_ls(worklane_dir: &Path, ids: bool) -> Result<()> {
None => String::new(),
};
// The codename between the id and the title, in the colour the board draws it in
// and with the same mark: the answer to "which campaign is this" is one word, and
// it should be the same word wherever it is read. A campaign filed without one
// spends nothing on it, the way an untagged card spends no row.
let codename = match campaign.codename.is_some() {
true => {
let label = campaign_label(&campaign.uuid, campaign.codename.as_deref());
format!("{} ", paint_cells(&[label], colored))
}
false => String::new(),
};
println!(
" ({}) {} | {}{}",
" ({}) {}{} | {}{}",
paint(short_id(&campaign.uuid), Color::Red, colored),
codename,
campaign.title,
standing.label(),
state,
+14 -1
View File
@@ -177,13 +177,22 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
continue;
}
// The same contract for the campaign picker, which is the other mode that owns
// the keyboard while it is open. Two calls rather than one combined pre-branch,
// because only one of the two can be open at a time and each reports for
// itself; the rules are `Board::search_key` and `Board::picker_key`, where a
// test can reach them.
if board.picker_key(key, screen) {
continue;
}
match key.code {
// One arm, because the two keys mean one thing: close what is open, and
// quit when there is nothing left to close. Two arms carrying one rule
// is how a later edit changes it for one key and not the other, which is
// what `q` quitting out from under an open ticket already was. The rule
// itself is `Board::dismiss`, where a test can reach it.
KeyCode::Esc | KeyCode::Char('q') => board.dismiss(),
KeyCode::Esc | KeyCode::Char('q') => board.dismiss(screen),
// The only key that leaves the board from an open ticket, which is why
// the footer names it there.
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
@@ -215,6 +224,10 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
// left that a vim hand would reach for. The clipboard is handed in rather
// than reached for inside `Board`, so the suite can drive both answers.
KeyCode::Char('y') => board.copy_selected_id(clipboard::copy),
// The way in to the campaign picker, like `/` is to the search prompt: from
// the next keypress on `picker_key` above has the keyboard. Free of every
// other binding, and `ctrl-c` is matched above this so quitting still wins.
KeyCode::Char('c') => board.open_picker(),
_ => {}
}
}
+1472 -75
View File
File diff suppressed because it is too large Load Diff
+111 -8
View File
@@ -389,14 +389,22 @@ fn status_paths(worklane_dir: &Path) -> Vec<(String, std::path::PathBuf)> {
.collect()
}
/// The three-tier search, run over `dirs`, returning the first tier that matched
/// The four-tier search, run over `dirs`, returning the first tier that matched
/// anything.
///
/// Three tiers, filled in one pass and consulted in order. A uuid prefix has to win
/// Four tiers, filled in one pass and consulted in order. A uuid prefix has to win
/// outright rather than join a flat list: ticket titles reference other tickets by id,
/// so an exact prefix match was reported as ambiguous against whichever title happened
/// to mention it.
///
/// **An exact codename wins over all three.** It is the one tier that is an exact match on
/// a field written for the purpose, so it cannot be a coincidence the way a substring can,
/// and a codename of `v1` is too short to be tried as an id at all. Only campaigns carry
/// the field, so for a ticket the tier is always empty and resolution is exactly what it
/// was. It lives here rather than in a campaign-only path for the reason the rest of this
/// function is shared: that would be a second copy of the precedence rules and a second
/// ambiguity message.
///
/// Shared by tickets and campaigns rather than written twice. A campaign is addressed
/// exactly the way a ticket is, and a second resolver would be a second copy of the
/// precedence rules to keep in step. Each entry pairs the name a match is reported
@@ -405,6 +413,7 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
let search_lower = search.to_lowercase();
let long_enough_for_an_id = search.chars().count() >= MIN_ID_SEARCH;
let mut by_codename: Vec<Found> = Vec::new();
let mut by_id: Vec<Found> = Vec::new();
let mut by_title: Vec<Found> = Vec::new();
let mut by_filename: Vec<Found> = Vec::new();
@@ -429,12 +438,17 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
.unwrap_or_default();
let uuid = filename.split('_').next().unwrap_or("");
// Case insensitive like the other three: a codename typed back off a listing
// has to resolve whatever case it was read in, which is the bargain the id
// tier already takes.
let is_codename = parse_codename(&content)
.is_some_and(|codename| codename.to_lowercase() == search_lower);
let by_prefix = long_enough_for_an_id && uuid.to_lowercase().starts_with(&search_lower);
let in_title = title.to_lowercase().contains(&search_lower);
// Still reaches the middle of a uuid, which the prefix tier cannot.
let in_filename = filename.to_lowercase().contains(&search_lower);
if !(by_prefix || in_title || in_filename) {
if !(is_codename || by_prefix || in_title || in_filename) {
continue;
}
@@ -444,7 +458,9 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
content,
uuid: uuid.to_string(),
};
if by_prefix {
if is_codename {
by_codename.push(found);
} else if by_prefix {
by_id.push(found);
} else if in_title {
by_title.push(found);
@@ -454,10 +470,11 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
}
}
Ok(match (by_id.is_empty(), by_title.is_empty()) {
(false, _) => by_id,
(true, false) => by_title,
(true, true) => by_filename,
Ok(match (by_codename.is_empty(), by_id.is_empty(), by_title.is_empty()) {
(false, _, _) => by_codename,
(true, false, _) => by_id,
(true, true, false) => by_title,
(true, true, true) => by_filename,
})
}
@@ -846,6 +863,13 @@ fn metadata_value_cell(name: &str, value: &str, colored: bool, campaign: &str) -
return paint(value, Color::Grey, colored);
}
// The same word in the same colour as the label a card draws, since `tag_color` is a
// pure function of it. No mark here: the field name has already said what this is,
// and the mark is what tells a campaign from a tag on a row that holds both.
if name == CODENAME_FIELD {
return paint(value, tag_color(value), colored);
}
if name == "Tags" {
return paint_tags(value, colored);
}
@@ -1133,6 +1157,66 @@ pub fn set_metadata_field(content: &str, field: &str, value: &str, title: &str)
/// board.
pub const CAMPAIGN_FIELD: &str = "Campaign";
/// The metadata field naming a campaign in a word, beside the uuid that addresses it.
///
/// A campaign is filed for a release or a migration, and those have names people already
/// use: `v1`, `beaver`. The uuid is what everything stores and the title is a sentence, so
/// neither is what a card has room to print. This is the short form, written by
/// `campaign add --codename` and nothing else.
///
/// Optional, and a campaign without one is not a lesser campaign: every campaign filed
/// before this existed has no field at all, which reads as unset the way an absent
/// Campaign field does.
pub const CODENAME_FIELD: &str = "Codename";
/// The mark a campaign carries where it is drawn as a label.
///
/// Not `#`, which is the tag marker: the two sit on the same row of a card and the row
/// would read as one list of tags with a stranger in it. A tilde is ASCII, so it renders
/// wherever `#` does, and it is not `@`, which reads as a person on every board anyone
/// has used.
///
/// One glyph, so the campaign on a card and the campaign in the picker are the same
/// thing said the same way.
pub const CAMPAIGN_MARK: &str = "~";
/// The campaign codename a file names, or nothing when it names none.
///
/// Absent, unset and empty are one answer, the bargain [`parse_campaign`] and
/// [`parse_tags`] both take: a campaign filed before the field existed carries no line at
/// all, and one whose line reads `_Not set_` has no codename either.
pub fn parse_codename(content: &str) -> Option<String> {
let value = parse_ticket_field(content, CODENAME_FIELD);
match is_unknown_value(&value) || value.trim().is_empty() {
true => None,
false => Some(value.trim().to_string()),
}
}
/// A campaign as a label: the mark, then the codename, or the short id when it has none.
///
/// The id is the fallback rather than the title, which is a sentence and would not fit the
/// row this is drawn on. It says little, which is the whole reason the codename field
/// exists, but it is addressable: `campaign show` takes it.
///
/// **A codename takes its own colour from [`tag_color`] and the fallback takes grey.** The
/// colour is what groups a campaign across the cards that carry it, and one word is one
/// colour in every view for the same reason a tag is. Grey on the id, rather than the red
/// a uuid is drawn in everywhere else, keeps a reserved meaning off a `TAG_COLORS` slot in
/// the one case where the label is an id: grey already means what a reader skips, which is
/// what a campaign with no codename has to say for itself.
///
/// A `Cell`, not a string, so the CLI paints it and the board makes a span of it, the way
/// a relation row already works. The bold is the board's: it is there to win a row against
/// the tags, and nothing in the CLI shares a line with them.
pub fn campaign_label(uuid: &str, codename: Option<&str>) -> Cell {
match codename {
Some(codename) => Cell::colored(format!("{CAMPAIGN_MARK}{codename}"), tag_color(codename)),
None => Cell::colored(format!("{CAMPAIGN_MARK}{}", short_id(uuid)), Color::Grey),
}
}
/// The campaign uuid a ticket names, or nothing when it names none.
///
/// Absent and unset are the same answer: a ticket that has never been assigned has no
@@ -1574,6 +1658,25 @@ fn section_body(lines: &[&str], heading: &str) -> Option<std::ops::Range<usize>>
Some(after..section_end(lines, after))
}
/// The first line of a section's body, or nothing when the section is absent or holds
/// only its placeholder.
///
/// For a view with one row to spend on prose: the board's campaign frame and its picker
/// both want the opening line of a description and have no room for the rest. Through
/// [`section_body`] rather than a scan of its own, so what counts as the section is
/// decided in one place, and the placeholder reads as nothing here the way it does to
/// `append`.
pub fn section_opening(content: &str, section: &Section) -> Option<String> {
let lines: Vec<&str> = content.lines().collect();
let body = section_body(&lines, section.heading)?;
lines[body]
.iter()
.map(|line| line.trim())
.find(|line| !line.is_empty() && *line != section.placeholder)
.map(|line| line.to_string())
}
/// Where the body's content ends, ignoring the blank lines that separate it from
/// whatever follows.
fn body_content_end(lines: &[&str], body: &std::ops::Range<usize>) -> usize {
+214
View File
@@ -642,3 +642,217 @@ fn an_ambiguous_campaign_lists_the_candidates() {
assert!(message.contains("v1 release"), "{message}");
assert!(message.contains("v2 release"), "{message}");
}
// ------------------------------------------------------------------ codenames --
/// The codename is what the board draws on every card in a campaign, since a uuid does
/// not fit there and a title is a sentence.
#[test]
fn campaign_add_writes_the_codename_under_the_id() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let out = run(
&temp,
&[
"campaign",
"add",
"--title",
"First public release",
"--codename",
"v1",
],
);
assert!(out.status.success(), "{}", stderr(&out));
let name = campaigns(&worklane).remove(0);
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
assert!(content.contains("- **Codename**: v1"), "{content}");
// Under the ID, because that is what it is: a second way to say which campaign this
// is, in a word rather than in thirty-six characters.
let id = content.find("- **ID**:").expect("no id");
let codename = content.find("- **Codename**:").expect("no codename");
let owner = content.find("- **Owner**:").expect("no owner");
assert!(id < codename && codename < owner, "{content}");
}
/// A campaign filed without one carries the line unset rather than not at all, the way
/// `add` writes an unset Due on every ticket: one shape of file is one thing for the
/// parser to be right about, and the line is there to fill in by hand.
#[test]
fn a_campaign_filed_without_a_codename_carries_the_field_unset() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
run(&temp, &["campaign", "add", "--title", "No codename here"]);
let name = campaigns(&worklane).remove(0);
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
assert!(content.contains("- **Codename**: _Not set_"), "{content}");
}
/// One word, checked at parse time like `--due` and `--priority`, because the board draws
/// it as a label with a mark and no quoting: `~beaver release` on that row reads as two
/// labels and the second one is not a campaign.
#[test]
fn a_codename_of_more_than_one_word_is_a_usage_error() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let out = run(
&temp,
&[
"campaign",
"add",
"--title",
"v1 release",
"--codename",
"beaver release",
],
);
assert_eq!(out.status.code(), Some(2), "{}", stderr(&out));
assert!(stderr(&out).contains("single word"), "{}", stderr(&out));
assert!(campaigns(&worklane).is_empty(), "a campaign was filed anyway");
}
#[test]
fn an_empty_codename_is_a_usage_error() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let out = run(&temp, &["campaign", "add", "--title", "v1 release", "--codename", ""]);
assert_eq!(out.status.code(), Some(2), "{}", stderr(&out));
assert!(campaigns(&worklane).is_empty(), "a campaign was filed anyway");
}
/// The listing is where the codename is read back, so it goes between the id and the
/// title with the mark the board draws it with: one word for one campaign, spelled the
/// same wherever it is shown.
#[test]
fn campaign_ls_names_the_codename_between_the_id_and_the_title() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_campaign(&worklane, "No codename here", CAMP_B);
run(
&temp,
&[
"campaign",
"add",
"--title",
"First public release",
"-c",
"v1",
],
);
let out = run(&temp, &["campaign", "ls"]);
let listing = stdout(&out);
assert!(listing.contains("~v1 First public release"), "{listing}");
// And a campaign without one spends nothing on it, the way an untagged card spends no
// row.
assert!(listing.contains(") No codename here"), "{listing}");
assert!(!listing.contains("~No codename"), "{listing}");
let _ = worklane;
}
/// `campaign show` renders its metadata as a table, so the field is there to read without
/// anything being written twice.
#[test]
fn campaign_show_renders_the_codename_in_its_metadata() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
run(
&temp,
&[
"campaign",
"add",
"--title",
"First public release",
"-c",
"v1",
],
);
let out = run(&temp, &["campaign", "show", "First public"]);
assert!(stdout(&out).contains("Codename"), "{}", stdout(&out));
assert!(stdout(&out).contains("v1"), "{}", stdout(&out));
let _ = worklane;
}
/// A codename nobody can type is half a field, so it resolves a campaign the way its
/// uuid and its title do. Exact, and ahead of all three: it is a match on a field written
/// for the purpose rather than a substring that could be a coincidence.
#[test]
fn a_campaign_resolves_by_its_codename() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
// Same file, plus a codename, since `create_campaign` writes none.
let path = worklane
.join("campaigns")
.join(format!("{}_{}.md", CAMP_A, slug("v1 release")));
let content = fs::read_to_string(&path).unwrap();
fs::write(
&path,
content.replace("- **Owner**:", "- **Codename**: beaver\n- **Owner**:"),
)
.unwrap();
let out = run(&temp, &["assign", "beaver", MEMBER]);
assert!(out.status.success(), "{}", stderr(&out));
assert!(
ticket(&worklane, MEMBER).contains(&format!("- **Campaign**: {CAMP_A}")),
"{}",
ticket(&worklane, MEMBER)
);
// And every other command that takes a campaign, since they share one resolver.
let out = run(&temp, &["campaign", "show", "beaver"]);
assert!(stdout(&out).contains("v1 release"), "{}", stdout(&out));
let out = run(&temp, &["ls", "--campaign", "beaver"]);
assert!(stdout(&out).contains("The member"), "{}", stdout(&out));
}
/// An exact codename beats a title that merely contains the search, which is the whole
/// reason it is a tier of its own: `v2` is a substring of `v2 release` and the exact
/// match has to win outright rather than be reported as ambiguous against it.
#[test]
fn an_exact_codename_beats_a_title_that_contains_the_search() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
let path = worklane
.join("campaigns")
.join(format!("{}_{}.md", CAMP_A, slug("v1 release")));
let content = fs::read_to_string(&path).unwrap();
fs::write(&path, content.replace("- **Owner**:", "- **Codename**: v2\n- **Owner**:")).unwrap();
let out = run(&temp, &["assign", "v2", MEMBER]);
assert!(out.status.success(), "{}", stderr(&out));
assert!(
ticket(&worklane, MEMBER).contains(&format!("- **Campaign**: {CAMP_A}")),
"the title tier won: {}",
ticket(&worklane, MEMBER)
);
}
/// A ticket carries no codename, so the tier is empty for one and ticket resolution is
/// exactly what it was. Pinned because the tier lives in the shared resolver: this is the
/// half of it that must not have changed.
#[test]
fn a_ticket_search_is_unaffected_by_the_codename_tier() {
let temp = TempDir::new().unwrap();
let worklane = board(&temp);
// The uuid prefix still wins over a title that quotes it, which is the precedence the
// three tiers were written for.
let out = run(&temp, &["show", "641e3d5"]);
assert!(stdout(&out).contains("The member"), "{}", stdout(&out));
let _ = worklane;
}