Compare commits

..
4 Commits
Author SHA1 Message Date
Ansho Rei 3892afe819 (2e05015) Show the campaign standing on its picker row, and bump to 0.32.21 2026-09-01 13:42:51 +02:00
Ansho ReiandClaude Opus 5 c81838efc6 Sort the backlog by due date, then priority
The backlog was the one column priority governed alone, which sat a p1
nobody had promised above a p3 due tomorrow. It has no entry stamp, so it
now takes the due date as the date `by_status_order` keys on: soonest
first, undated below every dated one, and priority then title as the
tiebreak, which is still the whole order among the undated ones.

`TicketItem::due_key` is where a due becomes an orderable date. Only a
plain `YYYY-MM-DD` counts, which is all `--due` has accepted since
daa0e79, with `due_date` cutting a legacy datetime back to its date.
Free text answers `None` and sinks with the unset ones rather than
sorting on its spelling: a due nobody can place on a calendar is
unknown, the same reading a missing stamp already gets.

The comparator stays the single function keyed on `Status`, so `ls`,
`ls --ids`, the board's columns and `campaign::members` move together.
The All tab keeps `by_priority_then_title`: that merge spans statuses,
so no single date governs it.

`ls_listed_tickets_sorted_alphabetically` gave its three tickets three
different due dates while asserting title order. They share one now, so
the case still tests the tiebreak it names rather than the new order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 01:10:41 +02:00
Ansho ReiandClaude Opus 5 cd7c99fe39 (d5a8a3f) Add make check, one command for fmt, clippy and the suite, and bump to 0.32.20
AGENTS.md pins `cargo fmt --check` and `cargo clippy --all-targets` as
clean, and 83d31cd is what happens when only memory enforces that: fmt
drifted to about 160 places across every file with the tool installed and
configured by default the whole time.

The decision the ticket wanted, taken: mechanise it, as one command. Not
CI, which a single-author tool with no pipeline anywhere does not want,
and not a hook, which is a per-clone opt-in the way `blame.ignoreRevsFile`
is and so cannot be relied on either. What was missing was never a
mechanism, it was one name to type: "remember to run fmt, clippy and the
tests" becomes `make check`.

Cheapest first, so a formatting slip is reported in a second rather than
after the suite. `-D warnings` is what turns clippy's opinion into an exit
code, since a warning printed into a wall of cargo output is unread rather
than clean. Verified each gate fails on its own: a misformatted function
and a `&Vec<u8>` parameter each exit 2 before the tests run.

Completions are inside `cargo test` rather than a target of their own.
d93eca6 put the check that loads the generated script into a real fish
there, so "check tests, check completions" is already one command, and a
second target would be a second thing to remember, which is the problem
this is solving.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 23:56:44 +02:00
Ansho ReiandClaude Opus 5 b63b60eefc (4dea61c) Load the completion script into fish and ask it what it offers, and bump to 0.32.19
Every check over the completions read the script as text. A `contains`
cannot tell a rule that fires from one whose condition stopped matching,
and that is how a completion actually breaks: the clap definition moves,
a list or a `__worklane_command_is` scope stops naming anything, and the
rule sits in the file offering nothing while every assertion passes.

So the generated script is sourced into a throwaway fish standing in a
real board, with this build's directory on the front of PATH, and
`complete -C` is compared against the ticket and the tag that board was
given. Four deliberate breakages were used to size it: renaming the `ls`
status scope, dropping `append` from `TAG_FLAGS`, renaming a flag in
`TICKET_FLAGS` and dropping `show` from `TICKET_COMMANDS`. All four now
fail, each naming the list at fault.

**Assert the values, not the flag names.** clap emits every option's name
on its own, so `--tags` and `--blocked-by` are offered with the whole
dynamic half deleted; the first draft asserted those names and caught
only one of the four. What the hand-written rules add is the candidates
after the flag, and that is what a board under the shell makes checkable.

Two traps, both paid for once. `complete -C` autoloads
`~/.config/fish/completions/worklane.fish`, so the first draft passed
against a deliberately broken scope because the copy installed in August
still had the working rule: `set fish_complete_path` with no value is
what makes the sourced script the only source, and without that line the
test cannot fail. And the script is written beside the board rather than
in it, since a rule that fires nothing falls back to listing the
directory and the script would read as an answer.

`fish --no-execute` comes with it as the floor: it catches a script that
does not parse. Narrower than it sounds, and measured rather than
assumed, so the limit is written on the test. An apostrophe in a `-d`
description partway down re-balances against the next quote and parses,
corrupting every rule in between; the same apostrophe in the last rule
reaches the end unbalanced and is caught.

`every_listed_command_is_a_real_subcommand` widens to every list that
names a command, `CAMPAIGN_COMMANDS`, `TAG_FLAGS` and the two nested
lists, so a stale entry fails by name instead of through a rule count.
The counts themselves stay hardcoded and now say why: the walkers go
clap → list and never see an extra entry, so the count is what catches
one, and deriving it from the lists it checks would grow with the bogus
entry and pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 23:54:48 +02:00
10 changed files with 639 additions and 44 deletions
+9 -5
View File
@@ -29,7 +29,7 @@
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Committed On`, `Submitted On`, `Completed On`, `Discarded On`, `Campaign`, `Status`. The last five are the ones no ticket is born with: `add` writes none of them, so they are inserted on demand, against `METADATA_ORDER`, which is also what keeps `Status` last
- The four stamps are `mv`'s, written by `set_status_stamp` from `Status::stamp_field`, and they **accumulate**: entering a status writes its field, re-entering restamps, and arriving anywhere removes the fields of every status *after* the target. One arrival rule keyed off `Status::ALL`, not a case per move, which is why a backward move truncates the journey at the target (`done` back to `reviewing` drops `Completed On`, anything back to `backlog` drops all three) and a forward skip under `-f` stamps only where it lands rather than fabricating the stages it jumped. A ticket that walks the whole flow ends with `Created At`, `Committed On`, `Submitted On` and `Completed On` side by side, so presence means *got this far and has not been sent back past it*, not *is here now* — `Status` is what says where it is. Not the history log either: these answer how far and when, once per stage, and every change along the way is the log's. `backlog` has no stamp, `Created At` already answers for it
- **`Discarded` is last in `Status::ALL`, and that placement is what makes the stamp rule fall out right.** Nothing sits after it, so a discard clears nothing: a ticket abandoned from reviewing keeps `Committed On` and `Submitted On`, and the file still says how far it got before it was dropped. It also makes every move out of discarded a backward move, so un-discarding needs `-f` without a rule of its own. `Discarded On` is its stamp, and `Completed On` stays untouched, because a discarded ticket was never done
- **Each status column is ordered by its own entry stamp, through `by_status_order`.** Priority is the clock in the backlog and that column keeps priority then title; past it the question changes, so committed sorts by `Committed On` ascending, reviewing by `Submitted On` ascending, and done and discarded by their stamp descending. Said once: the head of every column is what the reader acts on next. An unstamped ticket sinks below every stamped one in its column, because a missing time is unknown rather than ancient and unknown must not claim the head of a queue; equal stamps and both-unstamped fall through to `by_priority_then_title`. One function keyed on the `Status`, taken by both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members`, which is why those loops walk `Status::ALL` rather than `status_dirs()`. The stamps are read in `collect_ticket_items`' existing pass, the rule `criteria` and `tags` already hold, and compared as strings: `%Y-%m-%d %H:%M:%S` is lexicographic in chronological order, the property `Due` already relies on, so nothing parses a date at sort time
- **Each status column is ordered by its own date, through `by_status_order`.** Past the backlog that date is the entry stamp, so committed sorts by `Committed On` ascending, reviewing by `Submitted On` ascending, and done and discarded by their stamp descending. The backlog has no stamp of its own, so it sorts by `Due` ascending, through `TicketItem::due_key`. Said once: the head of every column is what the reader acts on next, and in the backlog that is the nearest deadline rather than the loudest priority — priority alone sat a p1 nobody had promised above a p3 due tomorrow. A ticket carrying no date sinks below every dated one in its column, because a missing time is unknown rather than ancient and unknown must not claim the head of a queue; equal dates and both-undated fall through to `by_priority_then_title`, which is still the whole order among undated backlog tickets. One function keyed on the `Status`, taken by both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members`, which is why those loops walk `Status::ALL` rather than `status_dirs()`. The dates are read in `collect_ticket_items`' existing pass, the rule `criteria` and `tags` already hold, and compared as strings: `%Y-%m-%d %H:%M:%S` and `%Y-%m-%d` are both lexicographic in chronological order, so nothing parses a date at sort time. `due_key` answers `None` for a `Due` that is not a plain `YYYY-MM-DD` after `due_date` has cut a legacy datetime back — free text is unknown, not a date, and sorting on its spelling would rank it against real deadlines
- 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
@@ -53,7 +53,8 @@ repo. Do not restate any of it in this file: a second copy is a copy that goes s
and this file is for what someone changing worklane's own code needs.
## Testing
- Run: `cargo test`
- **Run `make check` before committing**: `cargo fmt --check`, then `cargo clippy --all-targets -- -D warnings`, then `cargo test`, cheapest first. That is the whole of the enforcement, and it is deliberate rather than a stopgap: this repo has no CI and does not want any, and a git hook is a per-clone opt-in the way `blame.ignoreRevsFile` is, so neither can be relied on. What was missing was one name to type, so the two rules below are a command and not a memory. `-D warnings` is what makes clippy's opinion an exit code; a warning printed into a wall of cargo output is unread, not clean. The completion checks are inside `cargo test` rather than a target of their own, since a second thing to remember is the problem this solves
- Run one suite: `cargo test`
- Tests use `assert_cmd` and `assert_fs` for CLI testing
- `setup_worklane()` creates temp `.worklane/` with the four flow 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. **The fixtures deliberately do not create `discarded/`**, so every discard test runs against a board that predates the status and `mv_creates_the_discarded_directory_on_a_board_that_predates_it` is not the only thing exercising the on-demand creation
- `create_ticket()` writes fully-formed markdown files directly (no `--` separator for positional args in test commands)
@@ -62,8 +63,8 @@ and this file is for what someone changing worklane's own code needs.
- **`WORKLANE_KEEP_FIXTURES=1 cargo test` keeps the fixtures and prints each path.** Opt-in rather than kept-automatically-on-failure, because the assertions here carry the state they are about: a failing board test prints the rendered rows. The flag is read once when a fixture is made rather than at drop time, so the answer cannot change mid-test, and `Fixture::swept()` turns it off for the three tests that are about the guard itself and must not be failed by a reader's environment
- **Verify a claim about leaked fixtures against a clean temp dir, not against `/tmp`.** `TMPDIR=/tmp/scratch cargo test` then count what is left in it: `/tmp` still holds the historical leak, so counting there measures the past rather than the change
- 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:
- **`cargo clippy --all-targets` is clean, and `make check` is what says so. 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, `make check` runs it first, 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:
| setting | value | why |
|---|---|---|
@@ -111,6 +112,9 @@ and this file is for what someone changing worklane's own code needs.
- **What clap does and does not emit.** It emits the possible values of an *option*, which is why `mv --status <TAB>` needs nothing here, and nothing for a *positional*, which is why the `ls` status and the `completions` shell are listed in the fish half. Both lists are read off the enums with `possible_values`, never written out, so a fifth status appears in the script on its own
- **Position is counted, not inferred.** The four `__worklane_*` predicates all read `$tokens[2]` and the token count rather than using `__fish_seen_subcommand_from`, because `campaign ls` and `campaign show` are also an `ls` and a `show` that fish has seen, and because matching against the ticket list would run worklane again inside the condition. `first_arg_of` and `second_arg_of` count a top-level command's arguments, `nested_arg_of` matches a parent and a child so `campaign show <TAB>` can be told from `chown alice <TAB>`, which sit at the same token count, and `command_is` asks only which command this is, at any position in it
- **Every rule carrying `-l` needs a `__worklane_command_is`, and `every_rule_naming_an_option_is_scoped_to_a_command` is what enforces it.** A bare `complete -c worklane -l tag` does not just complete that option's values, it tells fish the whole tool accepts `--tag`: `worklane init --<TAB>` offered six options that only `relate` and `ls` have. Fixed in 55ee6e3. `__fish_seen_subcommand_from ls` is not the scope to use, for the nesting reason above
- **The strongest completion check loads the script into fish and asks it for candidates.** `fish_offers_the_commands_the_statuses_and_the_values` in `tests/cmd_completions.rs` sources the generated script into a throwaway shell standing in a real board, with this build's directory on the front of PATH, and compares `complete -C` against the ticket and the tag it put there. Every other test in the file reads the script as text, which cannot tell a rule that fires from one whose condition stopped matching, and that is how a completion actually breaks. **Assert the values, not the flag names**: clap emits every option's name on its own, so `--tags` and `--blocked-by` are offered with every hand-written rule deleted; what the dynamic half adds is what comes *after* the flag. Two traps, both paid for once: the shell must have `fish_complete_path` emptied, or `complete -C` autoloads `~/.config/fish/completions/worklane.fish` and answers from whatever version wrote that, which is a guard that cannot fail; and the script is written beside the board rather than in it, since a rule that fires nothing falls back to listing the directory
- **`fish --no-execute` is the floor under that, not an oracle.** It catches a script that does not parse, quotes still open at the end of the file or an unclosed block. Measured, not assumed: an apostrophe interpolated into a `-d` description partway down re-balances against the next quote and parses, corrupting every rule in between while the check passes; the same apostrophe in the last rule reaches the end unbalanced and is caught. Only fish gets this, because only fish gets a hand-written half
- **The rule counts in the completion tests are hardcoded on purpose.** The walkers go clap → list and never see an entry naming something that does not exist, so a bogus pair in `TAG_FLAGS` is caught by `every_tag_rule_takes_the_annotation_as_its_description` counting one rule too many. Deriving that number from the lists it checks would grow with the bogus entry and pass. The `seen` totals in the walkers are hardcoded for the mirror reason, and both carry the note
- **The five completion lists are kept honest by tests** that walk the clap definition and fail on an argument left out of them. `TICKET_COMMANDS` and `TICKET_SECOND_COMMANDS` by position, `TICKET_FLAGS`, `CAMPAIGN_COMMANDS`, `CAMPAIGN_NESTED_COMMANDS`, `CAMPAIGN_FLAGS` and `TAG_FLAGS` likewise, the last against the test-local `TAG_LIST_FLAGS` and `TAG_NEW_COMMANDS` for the tag arguments that deliberately get no rule. The walk is one function, `every_argument`, since the tests differ only in the id they look for. Each also asserts *how many* it found, so a walker that stopped finding arguments fails rather than passing every assertion by never running them
- **A campaign is named in three shapes and a tag in one**, which is why the lists are not one list: a campaign is `assign`'s first positional, the first argument of `campaign show` and `campaign set`, and `ls --campaign`'s value, and each needs a different fish rule. A tag is only ever an option value, and its values come from a different command
- **`TAG_FLAGS` holds pairs where the others hold names**, because the two options that take one tag are spelled differently: `ls --tag` filters on one and `append --tags` adds them, so a single rule naming both would tell fish that each command accepts the other's flag. One rule per pair, generated in `fish_dynamic`. `add --tags` and `set --tags` are in the test's `TAG_LIST_FLAGS` instead and get no rule: they take the *whole* list, so the token at the cursor is `bug,tui` and fish replaces a token entire, which would throw away what is already typed. The test walks both `tag` and `tags`, so the next one has to say which of the two it is
@@ -447,7 +451,7 @@ and this file is for what someone changing worklane's own code needs.
- **`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 `visibility` 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. It keeps priority then title where every other column takes `by_status_order`: the merge spans statuses, so no single entry stamp governs it
- 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. It keeps priority then title where every other column takes `by_status_order`: the merge spans statuses, so no single date governs it
- `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
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.32.18"
version = "0.32.21"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.32.18"
version = "0.32.21"
edition = "2024"
[dependencies]
+23 -1
View File
@@ -5,15 +5,37 @@
# release cannot end up half-done: no version bump left untagged, no tag without
# a bump.
.PHONY: help patch minor major version release install
.PHONY: help check patch minor major version release install
help:
@echo "make check fmt, clippy and the suite, in that order"
@echo "make patch bump $(CURRENT) -> next patch, amend into HEAD, tag"
@echo "make minor bump $(CURRENT) -> next minor, amend into HEAD, tag"
@echo "make major bump $(CURRENT) -> next major, amend into HEAD, tag"
@echo "make version print the current version"
@echo "make install cargo install --path . && worklane install-skill"
# The one command to run before committing. AGENTS.md pins fmt and clippy as clean and
# 83d31cd is what happens when only memory enforces that: fmt drifted to about 160 places
# across every file with the tool installed and configured the whole time. This is not CI,
# which a single-author tool with no pipeline anywhere does not want, and not a hook, which
# is a per-clone opt-in the way `blame.ignoreRevsFile` is. It is one name to type, so
# "remember to run fmt, clippy and the tests" becomes "run make check".
#
# Cheapest first, so a formatting slip is reported in a second rather than after the suite.
# `--all-targets` on clippy, matching the rule in AGENTS.md, so the tests are linted too.
# `-D warnings` is what makes clippy's opinion an exit code: the rule says clean, and a
# warning printed into a wall of cargo output is not clean, it is unread.
#
# Completions are in the suite rather than a step of their own. `cargo test` sources the
# generated script into a real fish and asks it for candidates, so "check tests, check
# completions" is one command already, and a second target would be a second thing to
# remember. The fish tests skip when fish is not installed, printing that they did.
check:
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
# Read from the [package] table of Cargo.toml, which is the version the binary
# reports through `--version`, so it is the single source of truth. The name is
# what finds this crate's own entry in Cargo.lock.
+12 -1
View File
@@ -8,7 +8,7 @@ Worklane is a local Kanban flow for agentic software development.
| `worklane` or `worklane tui [path...]` | Opens the board: one column per status, redrawn when the tree changes. Read only. Opens with done and discarded hidden, their counts in the footer; `d` rotates hide both, show done, show both, and back around. Arrows or `hjkl` to move, `enter` for detail, `pgup`/`pgdn` to scroll an open ticket or the campaign frame, whichever the selection is on, with a page indicator on its border 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, and a comment count in its bottom right corner, the number then `❞` in cyan, before the criteria count and absent entirely when nobody has commented; while one is selected a frame above the columns names it, shows three rows of its description and says how far it has got, and `q` on its border gives the whole board back; up from the top card of a column moves the selection to that frame, where the scroll keys page through the description, `enter` gives it half the board and takes the rows back again, and down returns to the column it came from, leaving the frame at whatever height it was. 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, discarded 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 ls [status]` | Lists tickets, each column in its own order: the backlog by due date, soonest first, then priority then title, with an undated ticket below every dated one; committed and reviewing by when the ticket entered them, oldest first; done and discarded newest first. 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. A campaign is addressed the same way, plus its exact codename, which wins over all three. Ends with the ticket's history: every comment on it and every change to its status, owner or tags, oldest first, each naming who made it |
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions. `--status discarded` is exempt and reachable from anywhere, for a ticket that will not be done; leaving `discarded` is a backward move and needs `-f`. Discarding is refused while open tickets are blocked by the ticket, `-f` overrides. Records a `status` entry in the ticket's history, after the move: a refused or no-op move records nothing. `--actor` names the writer of that entry |
| `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. `--tags` records a `tags` entry in the ticket's history, with the tags before and after, and it is the only field of this command's that is logged; `--actor` names the writer of that entry |
@@ -88,6 +88,17 @@ the command. A pipe holds 64 KiB, so a listing that fits lands in the buffer who
and the writer never learns the reader left, giving 0. Only output past that gets far
enough to be cut off. Either way nothing is printed to stderr.
## Checking
```sh
make check # cargo fmt --check, clippy -D warnings, cargo test
```
One command, cheapest first, and the whole of what enforces the formatting and lint rules:
there is no CI here and no hook. The completion tests inside it source the generated script
into a real fish and ask it what it would offer, so they skip, saying so, on a machine
without fish.
## Releasing
```sh
+30 -2
View File
@@ -512,8 +512,30 @@ mod tests {
fn every_listed_command_is_a_real_subcommand() {
let cli = command();
let known: Vec<&str> = cli.get_subcommands().map(|c| c.get_name()).collect();
for name in TICKET_COMMANDS.iter().chain(TICKET_SECOND_COMMANDS.iter()) {
assert!(known.contains(name), "no such subcommand: {name}");
// Every list that names a top-level command, not only the ticket ones. The others
// were reachable only through the rule counts below, which fail with `expected 3,
// got 4` and name nothing: a stale entry is a `complete` line whose condition never
// matches, so fish offers nothing and says nothing about why.
let top = TICKET_COMMANDS
.iter()
.chain(TICKET_SECOND_COMMANDS.iter())
.chain(CAMPAIGN_COMMANDS.iter())
.copied()
.chain(TAG_FLAGS.iter().map(|(command, _)| *command));
for name in top {
assert!(known.contains(&name), "no such subcommand: {name}");
}
for (parent, child) in CAMPAIGN_NESTED_COMMANDS.iter().chain(TAG_NESTED_COMMANDS.iter()) {
let sub = cli
.find_subcommand(parent)
.unwrap_or_else(|| panic!("no such subcommand: {parent}"));
assert!(
sub.find_subcommand(child).is_some(),
"`worklane {parent}` has no `{child}` subcommand"
);
}
}
@@ -627,6 +649,12 @@ mod tests {
.filter(|line| line.contains("(worklane tags"))
.collect();
// **Hardcoded on purpose, and not derivable from the lists above.** This number is
// what catches an entry naming a command or a flag that does not exist: the walkers
// go clap → list and never see an extra, so a bogus `("bogus", "nope")` in
// `TAG_FLAGS` produces a fourth rule and only this count notices. Writing it as
// `TAG_FLAGS.len() + TAG_NESTED_COMMANDS.len()` would grow with the bogus entry and
// pass, which is the improvement to not make.
assert_eq!(
reading.len(),
3,
+111 -6
View File
@@ -5081,12 +5081,14 @@ fn no_campaign_line(count: usize, selected: bool) -> Line<'static> {
])
}
/// One picker row: `(1b78a24) ~beaver What the campaign is for`.
/// One picker row: `(1b78a24) ~beaver What the campaign is for 0/1`.
///
/// The highlight is `REVERSED`, the way a selected card is, so the row reads the same
/// whatever colours are already on it. The summary is grey because it is context around the
/// two things being chosen between, and it is cut with an ellipsis rather than dropped: half
/// a sentence still says what a campaign is about, which is not true of half an id.
/// a sentence still says what a campaign is about, which is not true of half an id. The
/// standing trails it, grey like a card's criteria count, so how far each campaign has got
/// is on the list rather than only on the frame.
fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'static> {
let emphasis = match selected {
true => Modifier::REVERSED,
@@ -5121,9 +5123,28 @@ fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'stat
));
}
// The standing, `2/3`, is what the reader picks a campaign by, so it is reserved
// before the prose is cut, the way a corner is: half a count reads as the wrong
// number, so the whole of it drops when the row will not hold it. A campaign with no
// members shows nothing, the way a card with no criteria spends no corner on it.
let used_base = spans_width(&spans);
let standing = match campaign.standing.total {
0 => None,
_ => {
let text = format!("{}/{}", campaign.standing.done, campaign.standing.total);
let room = (width as usize).saturating_sub(used_base + 2);
if text.chars().count() <= room {
Some(text)
} else {
None
}
}
};
let standing_w = standing.as_ref().map_or(0, |text| text.chars().count() + 2);
// What the campaign is *called* takes the row first, and the prose takes what is left.
// Under three characters there is nothing left to say, the bargain `project_label` makes.
let used = spans_width(&spans);
let used = used_base + standing_w;
let summary = match campaign.summary().is_empty() {
true => campaign.title.as_str(),
false => campaign.summary(),
@@ -5140,6 +5161,14 @@ fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'stat
));
}
if let Some(text) = standing {
spans.push(Span::raw(" "));
spans.push(Span::styled(
text,
Style::default().fg(Color::Grey.into()).add_modifier(emphasis),
));
}
Line::from(spans)
}
@@ -9175,9 +9204,9 @@ approach";
.collect()
}
/// Each column is ordered by its own entry stamp, not by priority: committed is the
/// longest wait first, done is what just landed first. Every ticket here is a p2, so
/// the stamp is doing all of the work.
/// Every column past the backlog is ordered by its own entry stamp, not by priority:
/// committed is the longest wait first, done is what just landed first. Every ticket
/// here is a p2, so the stamp is doing all of the work.
#[test]
fn a_column_is_ordered_by_the_stamp_the_ticket_entered_it_with() {
let dir = board_dir();
@@ -9218,6 +9247,29 @@ approach";
assert_eq!(column_titles(&board, 3), ["Newer", "Older"]);
}
/// The backlog is the column with no entry stamp, so the due date is what orders it.
/// Every ticket here is a p2, so the due is doing all of the work, and the undated
/// one trails both dated ones rather than sitting among them.
#[test]
fn the_backlog_column_is_ordered_by_the_due_date() {
let dir = board_dir();
let card = |uuid: &str, title: &str, due: &str| {
let path = write_ticket(&dir, "backlog", uuid, title, "");
let body = std::fs::read_to_string(&path)
.unwrap()
.replace("- **Due**: 2026-12-31", &format!("- **Due**: {due}"));
std::fs::write(&path, body).unwrap();
};
card("11111111-0000-4000-8000-000000000000", "Later", "2026-09-03");
card("22222222-0000-4000-8000-000000000000", "Undated", "_Not set_");
card("33333333-0000-4000-8000-000000000000", "Sooner", "2026-09-01");
let board = boards(&[("only", &dir)]);
assert_eq!(column_titles(&board, 0), ["Sooner", "Later", "Undated"]);
}
/// The merge spans statuses, so no single stamp governs it and it keeps priority then
/// title. Pinned on done, where the column order and the merge order disagree: the
/// board would put the newest first and the merge puts the p1 first.
@@ -12645,6 +12697,59 @@ approach";
assert!(footer(&board, 100, 24).contains("↵ view"), "the footer is the board's");
}
/// The list is where a campaign is chosen from, so how far each has got belongs on the
/// row rather than only on the frame: `0/2` after the summary, where a card draws its
/// criteria count.
#[test]
fn the_picker_rows_carry_the_standing() {
let dir = board_dir();
let mut board = campaign_board(&dir);
board.open_picker(PickerKind::Campaign, SCREEN);
let rows = picker_rows(&board, 100, 24);
// V1 holds two open members, so two done of two held is not reached.
let v1 = &rows[row_with(&rows, short_id(V1))];
assert!(v1.contains("0/2"), "{v1:?}");
// BEAVER holds one open member.
let beaver = &rows[row_with(&rows, short_id(BEAVER))];
assert!(beaver.contains("0/1"), "{beaver:?}");
}
/// A campaign with no members has no standing to show, the way a card with no criteria
/// spends no corner on it: the row ends at the summary.
#[test]
fn a_picker_row_with_no_members_shows_no_standing() {
let dir = board_dir();
write_campaign(&dir, V1, "First public release", "v1", "For a public tag.");
let mut board = one_board(&dir);
board.open_picker(PickerKind::Campaign, SCREEN);
let rows = picker_rows(&board, 100, 24);
let row = &rows[row_with(&rows, short_id(V1))];
assert!(!row.contains('/'), "a blank campaign claimed a standing: {row:?}");
}
/// The standing gives way before the identity and the prose, and goes whole: half a
/// count reads as the wrong number, the rule a corner drops itself by.
#[test]
fn a_campaign_row_drops_the_standing_whole_when_it_will_not_fit() {
let dir = board_dir();
write_campaign(&dir, V1, "First public release", "v1", "Everything for a public tag.");
write_member_card(&dir, "In v1", "cli", V1);
let mut board = one_board(&dir);
board.open_picker(PickerKind::Campaign, SCREEN);
let full = picker_rows(&board, 100, 24);
let wide = &full[row_with(&full, short_id(V1))];
assert!(wide.contains('/'), "no standing on a wide row: {wide:?}");
let narrow = picker_rows(&board, 14, 24);
let tight = &narrow[row_with(&narrow, short_id(V1))];
assert!(!tight.contains('/'), "a count given up in pieces: {tight:?}");
}
/// A campaign with no codename shows the id once, not twice: the row already opens
/// with it, so the card's fallback would say nothing the second time.
#[test]
+145 -25
View File
@@ -3323,7 +3323,8 @@ impl TicketItem {
/// A slot per status rather than a lookup by field name, so a fifth status carrying
/// a stamp is a compile error here the way it is in [`Status::stamp_field`].
/// Backlog has none: nothing stamps it, and `Created At` is not an entry time, so
/// every ticket in that column answers `None` and the whole order is the fallback.
/// every ticket in that column answers `None` and [`TicketItem::due_key`] is what
/// orders it instead.
fn entry_stamp(&self, status: Status) -> Option<&str> {
match status {
Status::Backlog => None,
@@ -3333,6 +3334,22 @@ impl TicketItem {
Status::Discarded => self.discarded_on.as_deref(),
}
}
/// The date the ticket is due, or `None` for one carrying nothing orderable.
///
/// What the backlog is sorted on, standing in for the entry stamp the column does
/// not have. `YYYY-MM-DD` only, so lexicographic order is chronological order and
/// the comparison stays a string comparison like the stamps'. `--due` has refused
/// anything else since daa0e79, and [`due_date`] cuts a datetime written before
/// that, or by hand, back to its date.
///
/// Free text answers `None` rather than sorting on its spelling. A due nobody can
/// place on a calendar is unknown, the same reading a missing stamp gets, and
/// unknown must not claim a place in a queue ordered by time.
fn due_key(&self) -> Option<&str> {
let date = due_date(&self.due);
is_ymd(date).then_some(date)
}
}
/// The stamp a ticket carries for a status, or `None` for one it has not reached.
@@ -3538,8 +3555,7 @@ pub fn collect_ticket_items(status_path: impl AsRef<Path>) -> Result<Vec<TicketI
Ok(items)
}
/// The order the backlog is read in, and the tiebreak every other column falls back to:
/// priority first, title second.
/// The tiebreak every column falls back to: priority first, title second.
///
/// Named and exported because the board's All tab merges several boards' columns into
/// one and has to land in one order. A merge sorted a second way would put a p1 below a
@@ -3554,36 +3570,46 @@ pub fn by_priority_then_title(a: &TicketItem, b: &TicketItem) -> std::cmp::Order
/// The order one status column is read in, keyed on the status.
///
/// Priority is the clock in the backlog, and that column keeps exactly the order it has
/// always printed. Past the backlog the question changes: committed asks what has waited
/// longest, reviewing what was handed over first, done what just landed. The head of
/// every column is therefore what the reader acts on next, which is ascending by entry
/// stamp in committed and reviewing and descending in done and discarded, the way a
/// changelog reads.
/// Every column asks the same question, what the reader acts on next, and answers it
/// with the one date it has. Committed asks what has waited longest, reviewing what was
/// handed over first, done what just landed: ascending by entry stamp in committed and
/// reviewing, descending in done and discarded, the way a changelog reads. The backlog
/// carries no entry stamp, so what heads it is the date the work is wanted by, soonest
/// first. Priority ran that column alone until then, which sat a p1 nobody had promised
/// above a p3 due tomorrow.
///
/// A ticket with no stamp sinks below every stamped one in its column. A missing time is
/// unknown, not ancient, and unknown must not claim the head of a queue ahead of a wait
/// somebody can point at. Reading absence as the epoch would come free from the string
/// comparison and put every legacy ticket first on data nothing verified.
/// A ticket with no date sinks below every dated one in its column, whether that date is
/// a stamp or a due. A missing time is unknown, not ancient, and unknown must not claim
/// the head of a queue ahead of a deadline somebody can point at. Reading absence as the
/// epoch would come free from the string comparison and put every legacy ticket first on
/// data nothing verified.
///
/// The comparison is a string comparison. The stamp format is `%Y-%m-%d %H:%M:%S`, where
/// lexicographic order is chronological order, the same property `Due` already relies
/// on, so there is no date parsing at sort time. Equal stamps happen, `mv` writes whole
/// seconds, and they fall through to priority and title like everything else.
/// The comparison is a string comparison. The stamp format is `%Y-%m-%d %H:%M:%S` and a
/// due is `%Y-%m-%d`, both of which order lexicographically the way they order
/// chronologically, so there is no date parsing at sort time. Equal dates happen, `mv`
/// writes whole seconds and a due has no time at all, and they fall through to priority
/// and title like everything else.
pub fn by_status_order(status: Status, a: &TicketItem, b: &TicketItem) -> std::cmp::Ordering {
let by_stamp = match (a.entry_stamp(status), b.entry_stamp(status)) {
// One pair, so the rules below are written once. Which date a column is keyed on is
// the only thing that changes with the status.
let (left, right) = match status {
Status::Backlog => (a.due_key(), b.due_key()),
_ => (a.entry_stamp(status), b.entry_stamp(status)),
};
let by_date = match (left, right) {
(Some(left), Some(right)) => match status {
Status::Done | Status::Discarded => right.cmp(left),
_ => left.cmp(right),
},
(Some(_), None) => std::cmp::Ordering::Less,
(None, Some(_)) => std::cmp::Ordering::Greater,
// Both unstamped, which is every ticket in the backlog: the fallback is the
// whole order there rather than a tiebreak.
// Neither carries one, which is every undated ticket in the backlog: the
// fallback is the whole order between them rather than a tiebreak.
(None, None) => std::cmp::Ordering::Equal,
};
by_stamp.then_with(|| by_priority_then_title(a, b))
by_date.then_with(|| by_priority_then_title(a, b))
}
/// The environment variable that keeps a test's fixture directory on disk.
@@ -4649,6 +4675,16 @@ mod tests {
}
}
/// A listed ticket carrying a due value, which is what the backlog column is ordered
/// by. Built off [`listed`] rather than beside it, so a field added to `TicketItem`
/// is still filled in one place.
fn due_on(title: &str, level: u8, status: Status, due: &str) -> TicketItem {
TicketItem {
due: due.to_string(),
..listed(title, level, status, None)
}
}
/// Sorted the way the column is read, titles out, so a case reads as the order it
/// asserts rather than as a pair of comparisons.
fn ordered(status: Status, mut items: Vec<TicketItem>) -> Vec<String> {
@@ -4656,11 +4692,11 @@ mod tests {
items.into_iter().map(|item| item.title).collect()
}
/// The backlog is the one column priority still governs, and it prints exactly what
/// it always has: the stamps a ticket carries from an earlier trip through the flow
/// do not reach it, because backlog has no stamp of its own to sort on.
/// Undated backlog tickets keep exactly the order the column always printed: the
/// stamps a ticket carries from an earlier trip through the flow do not reach it,
/// because backlog has no stamp of its own to sort on.
#[test]
fn the_backlog_keeps_priority_then_title() {
fn undated_backlog_tickets_keep_priority_then_title() {
let items = vec![
listed("zebra", 5, Status::Backlog, None),
listed("alpha", 1, Status::Backlog, None),
@@ -4670,6 +4706,90 @@ mod tests {
assert_eq!(ordered(Status::Backlog, items), ["alpha", "beta", "zebra"]);
}
/// The due date is the backlog's clock, so the soonest deadline heads the column the
/// way the oldest wait heads committed. Priority is deliberately inverted against the
/// dates here: a p1 due last is still listed last.
#[test]
fn the_backlog_lists_the_soonest_due_date_first() {
let items = vec![
listed("undated", 1, Status::Backlog, None),
due_on("last", 1, Status::Backlog, "2026-09-03"),
due_on("first", 5, Status::Backlog, "2026-09-01"),
due_on("middle", 3, Status::Backlog, "2026-09-02"),
];
assert_eq!(ordered(Status::Backlog, items), ["first", "middle", "last", "undated"]);
}
/// A due nobody promised must not outrank one somebody did, whatever the priorities
/// say. This is the case the column got wrong before: the p1 sat on top.
#[test]
fn a_dated_backlog_ticket_sorts_above_an_undated_one_of_any_priority() {
let items = vec![
listed("undated", 1, Status::Backlog, None),
due_on("dated", 5, Status::Backlog, "2026-09-01"),
];
assert_eq!(ordered(Status::Backlog, items), ["dated", "undated"]);
}
/// A due carries no time, so two tickets wanted on the same day is the common case
/// rather than the rare one, and it falls through to priority and title.
#[test]
fn backlog_tickets_sharing_a_due_date_fall_back_to_priority_then_title() {
let same = "2026-09-01";
let items = vec![
due_on("zebra", 1, Status::Backlog, same),
due_on("beta", 3, Status::Backlog, same),
due_on("alpha", 3, Status::Backlog, same),
];
assert_eq!(ordered(Status::Backlog, items), ["zebra", "alpha", "beta"]);
}
/// `--due` has taken `YYYY-MM-DD` and nothing else since daa0e79, but a file written
/// before that or by hand can hold a datetime or free text. The datetime sorts on the
/// date inside it; the free text is unknown rather than a date, and sinks with the
/// unset ones instead of sorting on its spelling.
#[test]
fn a_backlog_due_that_is_not_a_plain_date_sorts_on_what_can_be_read_from_it() {
let items = vec![
due_on("prose", 1, Status::Backlog, "next friday"),
due_on("unset", 1, Status::Backlog, NOT_SET),
due_on("datetime", 5, Status::Backlog, "2026-09-01 09:30:00"),
];
assert_eq!(ordered(Status::Backlog, items), ["datetime", "prose", "unset"]);
}
/// The due is the backlog's clock and only the backlog's. Past it the entry stamp is
/// the question, and a deadline set on a committed ticket does not reorder the queue
/// of what has waited longest.
#[test]
fn a_due_date_does_not_reorder_a_column_past_the_backlog() {
for status in [
Status::Committed,
Status::Reviewing,
Status::Done,
Status::Discarded,
] {
let soon = TicketItem {
due: "2026-09-01".to_string(),
..listed("soon", 1, status, Some("2026-08-02 09:00:00"))
};
let items = vec![
soon,
listed("later", 1, status, Some("2026-08-01 09:00:00")),
];
let expected = match status {
Status::Done | Status::Discarded => ["soon", "later"],
_ => ["later", "soon"],
};
assert_eq!(ordered(status, items), expected, "{status:?}");
}
}
/// Committed and reviewing are queues: the head is what has waited longest, which is
/// where the reader picks next from.
#[test]
+226
View File
@@ -68,6 +68,232 @@ fn fish_is_offered_every_status() {
assert!(out.contains("-a 'backlog committed reviewing done discarded' -d status"));
}
/// A board holding one ticket and one tag, for the rules whose values come off a board.
///
/// Returned with the ticket's id and the tag, since the assertions are that those exact
/// strings are what fish offers.
fn board() -> (assert_fs::TempDir, String, String) {
let temp = assert_fs::TempDir::new().unwrap();
let mut init = Command::cargo_bin(BIN_NAME).unwrap();
init.current_dir(temp.path()).arg("init").assert().success();
let mut add = Command::cargo_bin(BIN_NAME).unwrap();
add.current_dir(temp.path())
.args(["add", "--title", "A ticket to complete", "--tags", "atag"])
.assert()
.success();
let mut ls = Command::cargo_bin(BIN_NAME).unwrap();
let listed = ls
.current_dir(temp.path())
.args(["ls", "--ids"])
.assert()
.success();
let listed = String::from_utf8(listed.get_output().stdout.clone()).unwrap();
let id = listed.split('\t').next().unwrap().trim().to_string();
(temp, id, "atag".to_string())
}
/// What fish would actually offer for a half-typed line, or `None` when fish is absent.
///
/// `complete -C` is fish's own answer to "what are the candidates here", so this asks the
/// question a person at a prompt asks rather than searching the script for the rule that
/// ought to produce the answer. Each candidate is a name and, after a tab, its description.
///
/// **The shell is pointed at the binary under test and stood in a real board**, which is
/// what makes the dynamic half testable at all: its rules are command substitutions calling
/// `worklane ls --ids` and `worklane tags`, so with no board and no binary they return
/// nothing and every assertion about them would pass on an empty answer. The directory of
/// `CARGO_BIN_EXE_worklane` goes on the front of PATH so the substitution runs this build
/// rather than whatever is installed.
///
/// **`fish_complete_path` is emptied first, and without that line this test cannot fail.**
/// `complete -C` autoloads completions for the command it is asked about, so a developer
/// who has ever run `worklane completions fish > ~/.config/fish/completions/worklane.fish`
/// gets that file merged into the answer. It was written by some earlier version of this
/// binary and answers for whatever the rules used to be: the first draft of this test
/// passed against a deliberately broken scope because the installed copy still had the
/// working one. Emptying the path is what makes the sourced script the only source.
fn candidates(board: &assert_fs::TempDir, line: &str) -> Option<Vec<String>> {
// Beside the board rather than in it: a rule that fires nothing falls back to listing
// the directory, and a script sitting in there would appear among the candidates and
// read like an answer.
let holder = assert_fs::TempDir::new().unwrap();
let path = holder.path().join("worklane.fish");
std::fs::write(&path, script("fish")).unwrap();
let bin_dir = std::path::Path::new(BIN_NAME).parent().unwrap();
let inherited = std::env::var("PATH").unwrap_or_default();
let asked = std::process::Command::new("fish")
.current_dir(board.path())
.env("PATH", format!("{}:{inherited}", bin_dir.display()))
.arg("-c")
.arg(format!(
"set fish_complete_path; source {}; complete -C '{line}'",
path.display()
))
.output();
match asked {
Ok(out) => Some(
String::from_utf8_lossy(&out.stdout)
.lines()
.map(str::to_string)
.collect(),
),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => None,
Err(err) => panic!("could not run fish: {err}"),
}
}
/// The name half of a candidate, dropping the description fish takes after the tab.
fn names(candidates: &[String]) -> Vec<&str> {
candidates
.iter()
.map(|line| line.split('\t').next().unwrap_or(line))
.collect()
}
/// **Ask fish what it offers, instead of asserting that the rule that should make it
/// offer that is in the file.**
///
/// Every other test here reads the script as text, which cannot tell a rule that fires
/// from one whose condition stopped matching. That is how a completion actually breaks:
/// the clap definition moves, a list or a `__worklane_command_is` scope no longer names
/// anything, and the rule sits in the file offering nothing. Loading it into a real fish
/// and asking for the candidates is the only check that can see the difference.
///
/// **Asserting the values, not only the names, is the point.** clap emits every option's
/// name on its own, so `--tags` and `--blocked-by` are offered whether or not the dynamic
/// half loaded: an assertion that they appear passes with every hand-written rule deleted.
/// What those rules add is the candidates *after* the flag, and that is what is pinned
/// here, against the board `board()` puts under the shell.
///
/// Descriptions are read off deliberately and not asserted: every option carrying a
/// hand-written rule currently loses the help text clap gave it, which is its own ticket
/// rather than something to pin as correct here.
///
/// **Skipped when fish is not on PATH, and it says so.** There is no CI here and fish is
/// the shell this tool is written for, so failing a machine that never had it would be a
/// guard nobody could satisfy. A missing fish means the check did not run, not that it
/// passed.
#[test]
fn fish_offers_the_commands_the_statuses_and_the_values() {
let (temp, id, tag) = board();
let Some(commands) = candidates(&temp, "worklane ") else {
eprintln!("skipped: fish is not on PATH, so nothing asked it for candidates");
return;
};
for command in [
"add", "ls", "show", "mv", "set", "append", "relate", "campaign",
] {
assert!(
names(&commands).contains(&command),
"`worklane <TAB>` never offers {command}"
);
}
// The `ls` status positional, which clap emits nothing for, so this answer comes from
// the dynamic half alone and an empty one means that half stopped loading.
let statuses = candidates(&temp, "worklane ls ").unwrap();
for status in ["backlog", "committed", "reviewing", "done", "discarded"] {
assert!(
names(&statuses).contains(&status),
"`worklane ls <TAB>` never offers {status}"
);
}
let shells = candidates(&temp, "worklane completions ").unwrap();
for shell in ["fish", "bash", "zsh"] {
assert!(
names(&shells).contains(&shell),
"`worklane completions <TAB>` never offers {shell}"
);
}
// Every rule whose values come off the board, one per list it is generated from.
let ticket_value = [
("worklane show ", "TICKET_COMMANDS"),
("worklane chown alice ", "TICKET_SECOND_COMMANDS"),
("worklane relate --blocked-by ", "TICKET_FLAGS"),
("worklane chown --clear ", "the chown --clear rule"),
];
for (line, list) in ticket_value {
let offered = candidates(&temp, line).unwrap();
assert!(
names(&offered).contains(&id.as_str()),
"`{line}<TAB>` never offers the one ticket on the board, so {list} is not reaching it: {offered:?}"
);
}
let tag_value = [
("worklane ls --tag ", "TAG_FLAGS"),
("worklane append --tags ", "TAG_FLAGS"),
("worklane tags set ", "TAG_NESTED_COMMANDS"),
];
for (line, list) in tag_value {
let offered = candidates(&temp, line).unwrap();
assert!(
names(&offered).contains(&tag.as_str()),
"`{line}<TAB>` never offers the one tag on the board, so {list} is not reaching it: {offered:?}"
);
}
}
/// **The script is handed to fish, which parses it without running it.**
///
/// The fish half is a hand-written `format!` string carrying single quotes, command
/// substitutions and backslash line continuations, and every text assertion in this file
/// is a `contains`, which a broken script satisfies exactly as well as a correct one.
/// `--no-execute` is the parse without the run.
///
/// **What it catches is a script that does not parse**: quotes still open at the end of
/// the file, an unclosed block. That is narrower than it sounds and the limit is worth
/// writing down, because it was measured rather than assumed. An apostrophe interpolated
/// into a `-d` description partway down the file re-balances against the next quote and
/// parses, corrupting every rule in between while this test passes; the same apostrophe in
/// the *last* rule reaches the end unbalanced and is caught. So this is a floor, not an
/// oracle, and `fish_offers_the_commands_the_statuses_and_the_flags` is the one that reads
/// what the rules actually do.
///
/// Only fish, because only fish gets a hand-written half. What the other four shells are
/// given is clap's output whole, which `no_other_shell_gets_the_fish_half` pins, so a
/// syntax error there would be clap's bug and not this repo's to catch.
///
/// **Skipped when fish is not on PATH, and it says so.** The trade is deliberate: there is
/// no CI here and fish is the shell this tool is written for, so failing a machine that
/// never had it would be a guard nobody could satisfy. A missing fish means the check did
/// not run, not that it passed.
#[test]
fn fish_parses_the_script_it_is_given() {
let temp = assert_fs::TempDir::new().unwrap();
let path = temp.path().join("worklane.fish");
std::fs::write(&path, script("fish")).unwrap();
let parsed = std::process::Command::new("fish")
.arg("--no-execute")
.arg(&path)
.output();
let out = match parsed {
Ok(out) => out,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
eprintln!("skipped: fish is not on PATH, so the generated script went unparsed");
return;
}
Err(err) => panic!("could not run fish: {err}"),
};
assert!(
out.status.success(),
"fish refuses the script `worklane completions fish` writes:\n{}",
String::from_utf8_lossy(&out.stderr)
);
}
#[test]
fn an_unknown_shell_is_a_usage_error() {
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
+81 -2
View File
@@ -114,14 +114,16 @@ fn ls_with_invalid_status_fails() {
.failure();
}
/// Title is the last tiebreak, so the three share a due date and a priority: anything
/// else here would be testing the due order instead, which has its own case.
#[test]
fn ls_listed_tickets_sorted_alphabetically() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "Zebra", "alice", "2026-06-01");
create_ticket(&worklane, "backlog", "Apple", "bob", "2026-07-01");
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-08-01");
create_ticket(&worklane, "backlog", "Apple", "bob", "2026-06-01");
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-06-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path())
@@ -744,6 +746,32 @@ fn create_stamped_ticket(
.unwrap();
}
/// A backlog ticket with the due date that column is ordered by.
///
/// Backlog only, the way [`create_stamped_ticket`] is one status at a time: the due is
/// what stands in for an entry stamp in the one column that has none, and `_Not set_`
/// passed here is the undated case rather than a separate helper.
fn create_due_ticket(
worklane_dir: &std::path::Path,
title: &str,
uuid: &str,
priority: &str,
due: &str,
) {
let body = format!(
"# {title}\n\n## Metadata\n\n- **ID**: {uuid}\n- **Priority**: {priority}\n\
- **Tags**: test\n- **Due**: {due}\n- **Owner**: alice\n\
- **Status**: backlog\n"
);
fs::write(
worklane_dir
.join("backlog")
.join(format!("{uuid}_{}.md", slug(title))),
body,
)
.unwrap();
}
fn positions(stdout: &str, titles: [&str; 3]) -> Vec<usize> {
titles
.iter()
@@ -828,6 +856,57 @@ fn ls_orders_done_by_the_newest_entry_stamp() {
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
}
/// The backlog has no entry stamp, so the due date is its clock and the soonest deadline
/// heads the column. The p1 here is due last and is listed last, which is exactly what
/// priority alone got wrong.
#[test]
fn ls_orders_the_backlog_by_the_soonest_due_date() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let at = |n: u8| format!("dddd000{n}-0000-0000-0000-000000000001");
create_due_ticket(&worklane, "Soonest", &at(1), "5", "2026-09-01");
create_due_ticket(&worklane, "Latest", &at(2), "1", "2026-09-03");
create_due_ticket(&worklane, "Between", &at(3), "3", "2026-09-02");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "backlog"]);
let stdout = get_stdout(&mut cmd);
let seen = positions(&stdout, ["Soonest", "Between", "Latest"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
// The overview lists the same column, so it has to agree with the narrowed listing
// rather than falling back to priority for the same tickets.
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).arg("ls");
let overview = get_stdout(&mut cmd);
let seen = positions(&overview, ["Soonest", "Between", "Latest"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{overview}");
}
/// A due nobody promised must not outrank one somebody did. The undated ticket here is
/// the most urgent of the three and still trails both, and among the dated ones the
/// equal due falls through to priority.
#[test]
fn ls_sinks_an_undated_backlog_ticket_below_the_dated_ones() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
let at = |n: u8| format!("eeee000{n}-0000-0000-0000-000000000001");
create_due_ticket(&worklane, "Undated", &at(1), "1", "_Not set_");
create_due_ticket(&worklane, "Urgent", &at(2), "3", "2026-09-01");
create_due_ticket(&worklane, "Relaxed", &at(3), "5", "2026-09-01");
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
cmd.current_dir(temp.path()).args(["ls", "backlog"]);
let stdout = get_stdout(&mut cmd);
let seen = positions(&stdout, ["Urgent", "Relaxed", "Undated"]);
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
}
/// A missing stamp is unknown, not ancient, so it sinks below every stamped ticket
/// rather than claiming the head of the queue. Every ticket on a board older than the
/// stamps is one of these.