Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72dbdec2ec | ||
|
|
528566d103 |
@@ -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`
|
||||
@@ -90,7 +93,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- **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 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 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, `campaign show`'s only argument 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
|
||||
- **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
|
||||
- **`ls --ids` is the machine-readable listing**, and one of the three outputs in the tree meant to be parsed: the short id, a tab, the title, unstyled. Two fields because fish reads what follows a tab as the description and a script reads `cut -f1`. It includes done, which the decorated listing leaves out, because a completion has to be able to name a finished ticket, and it skips a missing status directory rather than refusing, because an error printed over a shell prompt is worse than no candidates. The filters still apply, and an unknown `--campaign` is still refused
|
||||
- **`campaign ls --ids` is the same flag and the same two fields for the other object**, and it deliberately skips the member counting the decorated listing does: `members()` reads every ticket on the board, and the caller here is a shell filling in candidates on a keypress. It also prints nothing on an empty board, where the decorated listing prints a sentence, because a sentence offered as a candidate is worse than no candidates
|
||||
- **`worklane tags` is the third, and it is a command rather than a mode on `ls`.** Two reasons: `ls --tag <tag>` answers what carries a tag and cannot answer what tags exist, which is the question a grooming sweep starts from, and a `--tags` beside a `--tag` is one letter from a filter that means something else. Alphabetical and case sensitive, matching the filter, so `bug` and `Bug` list separately and land next to each other, which is where a near-duplicate is spotted. Every status, done included: a tag that has fallen out of use is still part of what the vocabulary has been. `assets/PLAN.md` used to tell the agent to count tags with a `show` per ticket, and now points here
|
||||
@@ -167,12 +170,18 @@ 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 set` is the only writer of a filed campaign's fields, and it carries the two scalars.** d637288 decided it: a `set` rather than a flag on something narrower, because the file has more than one editable thing and the moment somebody wants to fix a typo in a title there would be a second command to design. `--title`, which renames the file the way `set --title` does, and `--codename`. `campaign add` writing a field at creation is not a second writer, exactly as `add --title` and `set --title` coexist
|
||||
- **No `campaign set --description`, and that is the line, not an oversight.** `set` and `append` are a pair for a prose section: a way to replace a description with no way to add a paragraph is half of it. The two scalars have no append form at all, which is the same line `append` already draws for a ticket. `campaign_set_offers_no_description_and_no_owner` pins it. No `--owner` either, because nothing writes a campaign's Owner today and giving `set` one would settle by accident whether `chown` grows a campaign; and no `--clear`, because a wrong codename is replaced rather than emptied and `Clearable` is `SetArgs`'s, its variants being a ticket's fields
|
||||
- **The codename is written through `set_or_insert_metadata_field`, not `set_metadata_field`.** Every campaign filed before the field existed has no such line, and those are exactly the campaigns the command is for, which is the same reasoning that puts `assign` on the upsert. **`Codename` is therefore in `METADATA_ORDER`, directly after ID**, so an inserted one lands where `campaign_body` writes it and a campaign given a codename later is the same file as one filed with it. Nothing upserts it on a ticket, so its place in a ticket's order costs nothing
|
||||
- **One write path for tickets and campaigns.** `save_entry` is the body, `save_ticket` and `save_campaign` are the named wrappers, and `write_then_replace` and `find_entry_file` take the noun as a `&str` so a failure says "campaign" where it is one. A campaign file is a ticket file in every way that matters here, `<uuid>_<slug>.md` in a directory, and the rename happens only after the write has landed. Every message puts the noun mid-sentence so there is no capital to case
|
||||
- `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 +221,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 +355,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 +376,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
@@ -1503,7 +1503,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.19.0"
|
||||
version = "0.21.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.19.0"
|
||||
version = "0.21.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -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,11 @@ 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 set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, and `--codename`. At least one required. The only way to change a campaign after it is filed, and the way a campaign filed before codenames existed gets one. No `--description`: replacing prose without an `append` to add a paragraph is half a pair |
|
||||
| `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 |
|
||||
|
||||
+9
-3
@@ -158,9 +158,10 @@ 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 campaign set v1 --codename beaver # or --title, on one already filed
|
||||
worklane assign v1 1b78a24
|
||||
```
|
||||
|
||||
A campaign is the tickets that have to be finished **together** for one outcome. The test
|
||||
@@ -177,6 +178,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, and `campaign set` is how it gets one without refiling.
|
||||
|
||||
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.
|
||||
|
||||
+22
-7
@@ -206,15 +206,28 @@ 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 campaign set v1 --title "..." # replace the title or the codename
|
||||
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. `campaign set <campaign> --codename <word>` gives one to a
|
||||
campaign that is already filed, which is what every campaign filed before the field
|
||||
existed needs.
|
||||
|
||||
`campaign set` is the only way to change a campaign after it is filed, and it reaches the
|
||||
title and the codename only. There is no way to edit a campaign's description or its owner
|
||||
yet.
|
||||
|
||||
`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 +240,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
@@ -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),
|
||||
)
|
||||
}
|
||||
|
||||
+83
-2
@@ -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.
|
||||
///
|
||||
@@ -265,13 +286,24 @@ pub enum Command {
|
||||
/// What a campaign can be asked for.
|
||||
///
|
||||
/// No `mv`: a campaign has no status to move it to, its state is derived from its
|
||||
/// members. No `set` or `append` either, which is a gap rather than a decision, since
|
||||
/// nothing yet edits a campaign after it is filed.
|
||||
/// members.
|
||||
///
|
||||
/// No `append`, and therefore no `set --description`: `set` and `append` are a pair for a
|
||||
/// prose section, and a way to replace a description with no way to add a paragraph to one
|
||||
/// is half of it. That pair is its own ticket. `set` here carries the two scalars, which
|
||||
/// have no append form at all, the same line `append` already draws for a ticket.
|
||||
#[derive(clap::Subcommand)]
|
||||
pub enum CampaignCommand {
|
||||
/// File a new campaign
|
||||
Add(CampaignAddArgs),
|
||||
|
||||
/// Replace fields on an existing campaign
|
||||
///
|
||||
/// The only way to change a campaign after it is filed. `campaign add --codename` writes
|
||||
/// the field at creation the way `add --title` does for a ticket; this is what replaces
|
||||
/// it, so every campaign filed before the field existed can still be given one.
|
||||
Set(CampaignSetArgs),
|
||||
|
||||
/// List campaigns with their member counts
|
||||
Ls {
|
||||
/// Print one campaign per line as its id and title, tab separated, for a script
|
||||
@@ -292,6 +324,44 @@ pub enum CampaignCommand {
|
||||
},
|
||||
}
|
||||
|
||||
/// What can be replaced on a campaign that is already filed: its title and its codename.
|
||||
///
|
||||
/// The two scalars, and deliberately not the description. See [`CampaignCommand`].
|
||||
///
|
||||
/// No `--owner`: nothing writes a campaign's Owner today, and giving `set` one would settle
|
||||
/// by accident whether `chown` grows a campaign or `set` keeps the field, which is the
|
||||
/// one-field-one-writer question and not this command's to answer.
|
||||
///
|
||||
/// No `--clear`: nothing has asked to empty a codename, a wrong one is replaced rather than
|
||||
/// emptied, and the vocabulary is a real question — `Clearable` is `SetArgs`'s and its
|
||||
/// variants are a ticket's fields, so reusing it here would put a ticket's enum on a
|
||||
/// campaign and inventing a second one is a decision worth making on purpose.
|
||||
///
|
||||
/// The group makes at least one field mandatory, so a bare `worklane campaign set <c>` is a
|
||||
/// usage error rather than a silent no-op, exactly as it is for [`SetArgs`].
|
||||
#[derive(clap::Args)]
|
||||
#[command(group(
|
||||
clap::ArgGroup::new("campaign_set_fields")
|
||||
.required(true)
|
||||
.multiple(true)
|
||||
.args(["title", "codename"])
|
||||
))]
|
||||
pub struct CampaignSetArgs {
|
||||
/// Campaign UUID, title, filename or codename
|
||||
pub campaign: String,
|
||||
|
||||
/// Replace the campaign title, renaming the file to match
|
||||
#[arg(short, long, allow_hyphen_values = PROSE, value_parser = non_empty)]
|
||||
pub title: Option<String>,
|
||||
|
||||
/// Replace the codename, a single word to call the campaign by
|
||||
///
|
||||
/// The same parser `campaign add --codename` takes, so a codename is one thing however
|
||||
/// it was written.
|
||||
#[arg(short, long, value_parser = codename)]
|
||||
pub codename: Option<String>,
|
||||
}
|
||||
|
||||
/// What a campaign holds: a title, a description and an owner.
|
||||
///
|
||||
/// Deliberately narrower than [`AddArgs`]. There are no acceptance criteria, because a
|
||||
@@ -299,6 +369,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 +382,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>,
|
||||
|
||||
+6
-6
@@ -50,11 +50,11 @@ pub const CAMPAIGN_COMMANDS: [&str; 1] = ["assign"];
|
||||
|
||||
/// Nested subcommands whose first argument is a campaign, as `parent child`.
|
||||
///
|
||||
/// `campaign show` is the only one, and it is why the fish half needs a third position
|
||||
/// helper: its argument is the *third* token, where `__worklane_first_arg_of` reads the
|
||||
/// second and `__worklane_second_arg_of` counts a top-level command's arguments. Neither
|
||||
/// can tell `campaign show <TAB>` from `chown alice <TAB>` by position.
|
||||
pub const CAMPAIGN_NESTED_COMMANDS: [(&str, &str); 1] = [("campaign", "show")];
|
||||
/// `campaign show` and `campaign set`, and they are why the fish half needs a third
|
||||
/// position helper: their argument is the *third* token, where `__worklane_first_arg_of`
|
||||
/// reads the second and `__worklane_second_arg_of` counts a top-level command's arguments.
|
||||
/// Neither can tell `campaign show <TAB>` from `chown alice <TAB>` by position.
|
||||
pub const CAMPAIGN_NESTED_COMMANDS: [(&str, &str); 2] = [("campaign", "show"), ("campaign", "set")];
|
||||
|
||||
/// Options whose value is a campaign.
|
||||
pub const CAMPAIGN_FLAGS: [&str; 1] = ["campaign"];
|
||||
@@ -348,7 +348,7 @@ mod tests {
|
||||
|
||||
// A guard on the walker itself: if it stopped finding arguments, every assertion
|
||||
// above would pass by never running.
|
||||
assert_eq!(seen, 3, "expected assign, campaign show and ls --campaign");
|
||||
assert_eq!(seen, 4, "expected assign, campaign show, campaign set and ls --campaign");
|
||||
}
|
||||
|
||||
/// Tags have their own list because their values come from `worklane tags` rather than
|
||||
|
||||
+142
-21
@@ -7,7 +7,8 @@ use std::path::Path;
|
||||
|
||||
use crate::campaign::*;
|
||||
use crate::command::{
|
||||
AddArgs, AppendArgs, CampaignAddArgs, CheckArgs, ChownArgs, LsArgs, RelateArgs, SetArgs,
|
||||
AddArgs, AppendArgs, CampaignAddArgs, CampaignSetArgs, CheckArgs, ChownArgs, LsArgs,
|
||||
RelateArgs, SetArgs,
|
||||
};
|
||||
use crate::install;
|
||||
use crate::util::*;
|
||||
@@ -442,10 +443,19 @@ pub fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// What is being written, for the messages a failure carries.
|
||||
///
|
||||
/// A `&str` naming the thing rather than two copies of the write path: a campaign file is
|
||||
/// a ticket file in every way that matters here, `<uuid>_<slug>.md` in a directory, and the
|
||||
/// only difference is the word a failure has to use. Every message below puts it
|
||||
/// mid-sentence so there is no capital to case.
|
||||
const TICKET: &str = "ticket";
|
||||
const CAMPAIGN: &str = "campaign";
|
||||
|
||||
/// Write `content` over `path`, without ever leaving half a file behind.
|
||||
///
|
||||
/// Staged in a temp file and renamed into place, because `fs::write` truncates before
|
||||
/// it writes and a partial write would corrupt the ticket. The temp sits under
|
||||
/// it writes and a partial write would corrupt the file. The temp sits under
|
||||
/// `.worklane/` rather than beside the ticket, so a leftover from a hard kill is
|
||||
/// invisible to ticket lookup and to the listing instead of showing up as a stray
|
||||
/// untitled ticket.
|
||||
@@ -454,6 +464,7 @@ fn write_then_replace(
|
||||
path: &Path,
|
||||
filename: &str,
|
||||
content: &str,
|
||||
kind: &str,
|
||||
title: &str,
|
||||
) -> Result<()> {
|
||||
let temp = worklane_dir.join(format!(".wl-{}.tmp", filename));
|
||||
@@ -461,7 +472,8 @@ fn write_then_replace(
|
||||
if let Err(e) = fs::write(&temp, content) {
|
||||
let _ = fs::remove_file(&temp);
|
||||
return Err(anyhow!(
|
||||
"Could not stage the update for ticket '{}' at {}: {}",
|
||||
"Could not stage the update for {} '{}' at {}: {}",
|
||||
kind,
|
||||
title,
|
||||
temp.display(),
|
||||
e
|
||||
@@ -470,21 +482,29 @@ fn write_then_replace(
|
||||
|
||||
if let Err(e) = fs::rename(&temp, path) {
|
||||
let _ = fs::remove_file(&temp);
|
||||
return Err(anyhow!("Could not write ticket '{}' at {}: {}", title, path.display(), e));
|
||||
return Err(anyhow!(
|
||||
"Could not write {} '{}' at {}: {}",
|
||||
kind,
|
||||
title,
|
||||
path.display(),
|
||||
e
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The ticket file in `dir` carrying `uuid`.
|
||||
/// The file in `dir` carrying `uuid`, ticket or campaign.
|
||||
///
|
||||
/// Matched on the uuid, not the title. Titles are not unique, `add` allows duplicates
|
||||
/// on purpose, so a title scan could land on a different ticket than the one that was
|
||||
/// resolved: `mv <uuid-of-second>` moved the first ticket sharing its title.
|
||||
fn find_ticket_file(dir: &Path, uuid: &str, title: &str) -> Result<String> {
|
||||
/// resolved: `mv <uuid-of-second>` moved the first ticket sharing its title. The same holds
|
||||
/// for a campaign, whose file is named the same way.
|
||||
fn find_entry_file(dir: &Path, kind: &str, uuid: &str, title: &str) -> Result<String> {
|
||||
if uuid.trim().is_empty() || is_unknown_value(uuid) {
|
||||
return Err(anyhow!(
|
||||
"Ticket '{}' has no ID field, so its file cannot be located",
|
||||
"Could not locate the file for {} '{}': it has no ID field",
|
||||
kind,
|
||||
title
|
||||
));
|
||||
}
|
||||
@@ -507,7 +527,8 @@ fn find_ticket_file(dir: &Path, uuid: &str, title: &str) -> Result<String> {
|
||||
}
|
||||
|
||||
Err(anyhow!(
|
||||
"Could not find the file for ticket '{}' in {}",
|
||||
"Could not find the file for {} '{}' in {}",
|
||||
kind,
|
||||
title,
|
||||
dir.display()
|
||||
))
|
||||
@@ -537,7 +558,7 @@ fn move_ticket_file(
|
||||
let source = from.join(filename);
|
||||
let dest = to.join(filename);
|
||||
|
||||
write_then_replace(worklane_dir, &source, filename, content, title)?;
|
||||
write_then_replace(worklane_dir, &source, filename, content, TICKET, title)?;
|
||||
|
||||
// The content is correct and in one place by now, so a failure here leaves the
|
||||
// ticket where it started rather than half moved.
|
||||
@@ -660,7 +681,7 @@ pub fn cmd_mv(ticket_id: &str, target: Status, force: bool, start: &Path) -> Res
|
||||
)?;
|
||||
|
||||
let found_filename =
|
||||
find_ticket_file(¤t_path, &parse_ticket_field(&resolved, "ID"), &title)?;
|
||||
find_entry_file(¤t_path, TICKET, &parse_ticket_field(&resolved, "ID"), &title)?;
|
||||
|
||||
move_ticket_file(
|
||||
&worklane_dir,
|
||||
@@ -756,21 +777,56 @@ fn save_ticket(
|
||||
new_title: Option<&String>,
|
||||
content: &str,
|
||||
) -> Result<()> {
|
||||
let status_path = worklane_dir.join(status);
|
||||
let filename = find_ticket_file(&status_path, uuid, title)?;
|
||||
let path = status_path.join(&filename);
|
||||
let dir = worklane_dir.join(status);
|
||||
save_entry(worklane_dir, &dir, TICKET, uuid, title, new_title, content)
|
||||
}
|
||||
|
||||
write_then_replace(worklane_dir, &path, &filename, content, title)?;
|
||||
/// The same for a campaign, whose directory is `campaigns/` and which sits in no status.
|
||||
///
|
||||
/// A named wrapper rather than a `save_entry` at the call site, so the campaign handler
|
||||
/// reads the way the ticket handlers do and neither has to know which directory the other
|
||||
/// writes to.
|
||||
fn save_campaign(
|
||||
worklane_dir: &Path,
|
||||
uuid: &str,
|
||||
title: &str,
|
||||
new_title: Option<&String>,
|
||||
content: &str,
|
||||
) -> Result<()> {
|
||||
let dir = campaigns_dir(worklane_dir);
|
||||
save_entry(worklane_dir, &dir, CAMPAIGN, uuid, title, new_title, content)
|
||||
}
|
||||
|
||||
// The uuid is kept, so the new name cannot collide with another ticket, and an
|
||||
/// Write a file back where it was, renaming it when the title changed.
|
||||
///
|
||||
/// One body for tickets and campaigns. Both are `<uuid>_<slug>.md` in a directory, both are
|
||||
/// written through `write_then_replace` so a failure leaves no half file, and both rename
|
||||
/// only after the write has landed: renaming first and writing second is what leaves a file
|
||||
/// under a name that does not match what is in it.
|
||||
fn save_entry(
|
||||
worklane_dir: &Path,
|
||||
dir: &Path,
|
||||
kind: &str,
|
||||
uuid: &str,
|
||||
title: &str,
|
||||
new_title: Option<&String>,
|
||||
content: &str,
|
||||
) -> Result<()> {
|
||||
let filename = find_entry_file(dir, kind, uuid, title)?;
|
||||
let path = dir.join(&filename);
|
||||
|
||||
write_then_replace(worklane_dir, &path, &filename, content, kind, title)?;
|
||||
|
||||
// The uuid is kept, so the new name cannot collide with another entry, and an
|
||||
// unchanged slug means there is nothing to rename.
|
||||
if let Some(new_title) = new_title {
|
||||
let renamed = format!("{}_{}.md", uuid, slug(new_title));
|
||||
if renamed != filename {
|
||||
let destination = status_path.join(&renamed);
|
||||
let destination = dir.join(&renamed);
|
||||
fs::rename(&path, &destination).map_err(|e| {
|
||||
anyhow!(
|
||||
"Ticket '{}' was updated but could not be renamed to {}: {}",
|
||||
"Could not rename {} '{}' to {} after updating it: {}",
|
||||
kind,
|
||||
title,
|
||||
destination.display(),
|
||||
e
|
||||
@@ -1037,7 +1093,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,12 +1115,13 @@ 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(),
|
||||
);
|
||||
|
||||
write_then_replace(&worklane_dir, &path, &filename, &body, title)?;
|
||||
write_then_replace(&worklane_dir, &path, &filename, &body, CAMPAIGN, title)?;
|
||||
|
||||
println!("Created campaign: {}", filename);
|
||||
Ok(())
|
||||
@@ -1099,9 +1161,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,
|
||||
@@ -1153,6 +1228,52 @@ pub fn cmd_tags(worklane_dir: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Replace fields on a campaign that is already filed.
|
||||
///
|
||||
/// `cmd_set` for a campaign, and built out of the same parts: `set_title` for the heading,
|
||||
/// `set_metadata_field` for the field, `apply` for whether an edit changed anything, and
|
||||
/// `report` for what it says afterwards. Nothing about writing a field lives twice, which is
|
||||
/// the shape `cmd_chown` already took.
|
||||
///
|
||||
/// The **codename is inserted when the campaign has no such line**, rather than refused.
|
||||
/// `set_metadata_field` refuses a field that is not there, which is right for the fields
|
||||
/// `add` writes; every campaign filed before the field existed has none, and those are
|
||||
/// exactly the campaigns this command is for. So it goes through
|
||||
/// `set_or_insert_metadata_field`, the upsert `assign` already uses for the Campaign field
|
||||
/// on a ticket, for the same reason.
|
||||
///
|
||||
/// No-op detection compares the whole file, the way `set` and `chown` do, so setting a
|
||||
/// codename a campaign already carries writes nothing.
|
||||
pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let campaign = resolve_campaign(&args.campaign, &worklane_dir)?;
|
||||
let title = campaign.title.clone();
|
||||
|
||||
let mut content = campaign.content.clone();
|
||||
let mut changed: Vec<&str> = Vec::new();
|
||||
|
||||
if let Some(new_title) = &args.title {
|
||||
let next = set_title(&content, new_title)?;
|
||||
apply(&mut content, &mut changed, "title", next);
|
||||
}
|
||||
|
||||
if let Some(codename) = &args.codename {
|
||||
let next = set_or_insert_metadata_field(&content, CODENAME_FIELD, codename, &title)?;
|
||||
apply(&mut content, &mut changed, "codename", next);
|
||||
}
|
||||
|
||||
if changed.is_empty() {
|
||||
report(&[], &title, "Updated");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let renamed = changed.contains(&"title").then_some(()).and(args.title.as_ref());
|
||||
save_campaign(&worklane_dir, &campaign.uuid, &title, renamed, &content)?;
|
||||
|
||||
report(&changed, args.title.as_ref().unwrap_or(&title), "Updated");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Show a campaign, then its members grouped by status.
|
||||
///
|
||||
/// Every status is shown, done included, unlike `ls`, which leaves done out of its
|
||||
|
||||
+15
-1
@@ -71,6 +71,7 @@ fn main() -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_campaign_ls(&worklane_dir, ids)
|
||||
}
|
||||
CampaignCommand::Set(args) => cmd_campaign_set(&args, &start),
|
||||
CampaignCommand::Show { campaign } => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_campaign_show(&campaign, &worklane_dir)
|
||||
@@ -177,13 +178,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 +225,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
File diff suppressed because it is too large
Load Diff
+120
-9
@@ -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
|
||||
@@ -1177,8 +1261,16 @@ pub fn parse_tags(content: &str) -> Vec<String> {
|
||||
/// stamps follow `Created At`, since they answer the same question it does about a
|
||||
/// later moment, and they are in flow order for a reader who sees one after another
|
||||
/// across a board.
|
||||
const METADATA_ORDER: [&str; 11] = [
|
||||
///
|
||||
/// `Codename` is a *campaign's* field and sits here for the same reason Campaign does: this
|
||||
/// is the one list that decides where an inserted field lands, and a campaign filed before
|
||||
/// the field existed is precisely the file `campaign set --codename` has to insert into.
|
||||
/// Directly after ID, because that is where `campaign_body` writes it, so a campaign given
|
||||
/// a codename later ends up with the same file as one filed with it. Nothing ever upserts
|
||||
/// it on a ticket, so its place in a ticket's order costs nothing.
|
||||
const METADATA_ORDER: [&str; 12] = [
|
||||
"ID",
|
||||
CODENAME_FIELD,
|
||||
"Priority",
|
||||
"Tags",
|
||||
"Due",
|
||||
@@ -1574,6 +1666,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 {
|
||||
|
||||
@@ -144,6 +144,21 @@ fn find(worklane: &Path, uuid: &str) -> PathBuf {
|
||||
panic!("no file for ticket {uuid}");
|
||||
}
|
||||
|
||||
/// A campaign's content by uuid, found rather than named, since `campaign set --title`
|
||||
/// renames the file and a test that named it would be asserting the old name.
|
||||
fn campaign_file(worklane: &Path, uuid: &str) -> String {
|
||||
for entry in fs::read_dir(worklane.join("campaigns"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
{
|
||||
if entry.file_name().to_string_lossy().starts_with(uuid) {
|
||||
return fs::read_to_string(entry.path()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
panic!("no file for campaign {uuid}");
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path, uuid: &str) -> String {
|
||||
fs::read_to_string(find(worklane, uuid)).unwrap()
|
||||
}
|
||||
@@ -642,3 +657,459 @@ 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;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- campaign set --
|
||||
|
||||
/// The point of the command: a campaign already on the board can be given a codename,
|
||||
/// which `campaign add --codename` cannot do because `add` files a new one.
|
||||
#[test]
|
||||
fn campaign_set_gives_a_filed_campaign_a_codename() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1 release", "--codename", "beaver"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("Updated codename"), "{}", stdout(&out));
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.contains("- **Codename**: beaver"), "{content}");
|
||||
}
|
||||
|
||||
/// `create_campaign` writes no Codename line at all, which is every campaign filed before
|
||||
/// the field existed, so the insertion path is the one this command is actually for.
|
||||
/// It lands under the ID, where `campaign add` writes it, so a campaign given a codename
|
||||
/// later is the same file as one filed with it.
|
||||
#[test]
|
||||
fn the_codename_is_inserted_under_the_id_when_the_line_is_absent() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
assert!(
|
||||
!campaign_file(&worklane, CAMP_A).contains("Codename"),
|
||||
"the fixture changed"
|
||||
);
|
||||
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
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}");
|
||||
}
|
||||
|
||||
/// One parser, so a codename is one thing however it was written. The board draws it as a
|
||||
/// label with a mark and no quoting, and that does not depend on which command wrote it.
|
||||
#[test]
|
||||
fn campaign_set_validates_the_codename_the_way_add_does() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
for value in ["two words", ""] {
|
||||
let out = run(&temp, &["campaign", "set", "v1 release", "--codename", value]);
|
||||
assert_eq!(out.status.code(), Some(2), "{value:?}: {}", stderr(&out));
|
||||
assert!(
|
||||
!campaign_file(&worklane, CAMP_A).contains("Codename"),
|
||||
"{value:?} was written"
|
||||
);
|
||||
}
|
||||
|
||||
// And the message is the one `campaign add` gives, since the parser is the same.
|
||||
let out = run(&temp, &["campaign", "set", "v1 release", "--codename", "two words"]);
|
||||
assert!(stderr(&out).contains("single word"), "{}", stderr(&out));
|
||||
}
|
||||
|
||||
/// A bare `campaign set <campaign>` is a usage error rather than a silent no-op, exactly
|
||||
/// as it is for `set`.
|
||||
#[test]
|
||||
fn campaign_set_with_no_field_is_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1 release"]);
|
||||
assert_eq!(out.status.code(), Some(2), "{}", stderr(&out));
|
||||
assert!(
|
||||
!campaign_file(&worklane, CAMP_A).contains("Codename"),
|
||||
"something was written"
|
||||
);
|
||||
}
|
||||
|
||||
/// Replacing the title renames the file, keeping the uuid, the way `set --title` does. That
|
||||
/// is the reason this is a `set` rather than a flag on something narrower.
|
||||
#[test]
|
||||
fn campaign_set_renames_the_file_with_the_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
// A member first, so the rename has something to break.
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"set",
|
||||
"v1 release",
|
||||
"--title",
|
||||
"First public release",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let names = campaigns(&worklane);
|
||||
assert!(
|
||||
names.contains(&format!("{CAMP_A}_first-public-release.md")),
|
||||
"not renamed: {names:?}"
|
||||
);
|
||||
assert!(
|
||||
!names.contains(&format!("{CAMP_A}_v1-release.md")),
|
||||
"the old file is still there: {names:?}"
|
||||
);
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.starts_with("# First public release\n"), "{content}");
|
||||
// The uuid is kept, so membership survives the rename: it is stored on the member as
|
||||
// the uuid, and nothing has to be rewritten when the campaign is renamed.
|
||||
assert!(content.contains(&format!("- **ID**: {CAMP_A}")), "{content}");
|
||||
let out = run(&temp, &["ls", "--campaign", "First public release"]);
|
||||
assert!(
|
||||
stdout(&out).contains("The member"),
|
||||
"membership was lost: {}",
|
||||
stdout(&out)
|
||||
);
|
||||
}
|
||||
|
||||
/// Both fields in one call, since the group is `multiple`.
|
||||
#[test]
|
||||
fn campaign_set_takes_the_title_and_the_codename_together() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"set",
|
||||
"v1 release",
|
||||
"-t",
|
||||
"First public release",
|
||||
"-c",
|
||||
"v1",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("title, codename"), "{}", stdout(&out));
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.starts_with("# First public release\n"), "{content}");
|
||||
assert!(content.contains("- **Codename**: v1"), "{content}");
|
||||
}
|
||||
|
||||
/// The whole-file comparison `set` and `chown` use, so writing what is already there
|
||||
/// writes nothing and says so.
|
||||
#[test]
|
||||
fn setting_the_codename_a_campaign_already_has_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
let out = run(&temp, &["campaign", "set", "v1", "-c", "v1"]);
|
||||
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("No changes"), "{}", stdout(&out));
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was rewritten");
|
||||
}
|
||||
|
||||
/// A codename set here resolves the campaign afterwards, which is the whole point of the
|
||||
/// field being typable: the tier is in the shared resolver, not in `campaign add`.
|
||||
#[test]
|
||||
fn a_codename_set_afterwards_resolves_the_campaign() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "beaver"]);
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
/// Nothing else in the file moves. A campaign carries prose and an owner this command
|
||||
/// cannot reach, and a hand-written section has to survive an edit to a field.
|
||||
#[test]
|
||||
fn content_the_command_cannot_reach_survives_a_set() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let path = worklane
|
||||
.join("campaigns")
|
||||
.join(format!("{}_{}.md", CAMP_A, slug("v1 release")));
|
||||
let original = fs::read_to_string(&path).unwrap();
|
||||
fs::write(
|
||||
&path,
|
||||
original.replace("## Metadata", "## Notes\nA handwritten note.\n\n## Metadata"),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.contains("A handwritten note."), "{content}");
|
||||
assert!(content.contains("What has to ship together."), "{content}");
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
assert!(!content.contains("**Status**"), "a status was invented: {content}");
|
||||
}
|
||||
|
||||
/// A campaign that does not resolve leaves everything alone, the answer `assign` already
|
||||
/// gives an unknown campaign.
|
||||
#[test]
|
||||
fn an_unknown_campaign_is_refused_and_nothing_is_written() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "nothing-by-that-name", "-c", "v1"]);
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
assert!(stderr(&out).contains("No campaign found"), "{}", stderr(&out));
|
||||
assert!(
|
||||
!campaign_file(&worklane, CAMP_A).contains("Codename"),
|
||||
"something was written"
|
||||
);
|
||||
assert!(
|
||||
!campaign_file(&worklane, CAMP_B).contains("Codename"),
|
||||
"something was written"
|
||||
);
|
||||
}
|
||||
|
||||
/// No `--description`: `set` and `append` are a pair for a prose section, and a way to
|
||||
/// replace a description with no way to add a paragraph is half of it. Pinned so the
|
||||
/// omission stays a decision rather than becoming an oversight somebody fills in.
|
||||
#[test]
|
||||
fn campaign_set_offers_no_description_and_no_owner() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "--help"]);
|
||||
let help = stdout(&out);
|
||||
|
||||
assert!(help.contains("--codename"), "{help}");
|
||||
assert!(help.contains("--title"), "{help}");
|
||||
assert!(!help.contains("--description"), "{help}");
|
||||
assert!(!help.contains("--owner"), "{help}");
|
||||
assert!(!help.contains("--clear"), "{help}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user