Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
108e21ad7f | ||
|
|
26b93f8f53 | ||
|
|
7126138d46 | ||
|
|
3592584747 |
@@ -125,6 +125,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Appending to a numbered section continues from the count of steps already there and does not renumber what is above it, so a handwritten line in the section survives exactly as written
|
||||
- Appending to an empty section replaces the placeholder rather than following it, or the ticket would read `_No description provided._` above its description
|
||||
- An empty value is a paragraph break for the three sections and a usage error for the scalars, via `non_empty` and `clearable` in `command.rs`. Neither spells clearing, and both errors name the flag that does
|
||||
- **A call whose values are *every one* blank is refused, by `replaced_items` for `set` and `appended_items` for `append`.** The check is the section's rather than the object's, so `campaign set --description` shares it. What differs is the way out, which is why `replaced_items` takes it as an argument: a ticket's section is emptied with `--clear <field>` and a campaign's description cannot be emptied at all, so a single hard-coded tail would name a flag that does not exist on one of the two
|
||||
|
||||
### Clearing a Field
|
||||
- **`set --clear <field>` is the one way to take a value away, and it is a flag with the field as its value.** Not a per-field `--clear-due`, which is a flag per field to keep in step with the field it undoes, and not an empty value, which is already a paragraph break for a section and would make an accidentally empty variable a silent delete. Repeatable, so one call empties as many fields as it likes
|
||||
@@ -185,9 +186,14 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- `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 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
|
||||
- **`campaign set` and `campaign append` are the only writers of a filed campaign's fields.** d637288 decided the command: 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. `set` carries `--title`, which renames the file the way `set --title` does, `--description` and `--codename`; `append` carries `--description` alone. `campaign add` writing a field at creation is not a second writer, exactly as `add --title` and `set --title` coexist
|
||||
- **Replacing a codename the campaign already has needs `--force`.** Once a campaign has one it is referred to by it: it is on every card in the campaign, it is what resolves the campaign at the command line, and it is in somebody's shell history. Changing it silently is the mistake `install-skill --force` exists to prevent, so it is refused and the refusal names both words and the flag rather than leaving it to be found. Checked before any edit is applied, like `SetArgs::contested`, so a call also carrying `--title` writes neither field. Setting the codename a campaign already carries stays a **no-op, not a refusal** — `--force` is about overwriting a *different* word, which is the same division `install::Outcome` draws between `Unchanged` and `Refused`. `--force` guards the codename alone: a campaign always has a title, so guarding that would mean the flag was always required
|
||||
- **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 description arrived as a pair, `set --description` and `campaign append`, 32e98ab.** Never one without the other: for a prose section `set` replaces and `append` adds, and a way to replace a description with no way to add a paragraph is the half that is easy to reach for and wrong, since replacing a description to add a sentence to it is how the rest of it gets lost. The two scalars have no append form at all, which is the same line `append` already draws for a ticket, and `campaign_append_offers_only_the_description` pins that. Neither flag takes `--force`: a description is prose written to be revised, the same reason `tags set --annotation` has none
|
||||
- **`append` is a campaign's own subcommand, not the top-level `append`.** That one resolves a ticket, and one positional naming either object is the ambiguity `resolve_in` makes real: its tiers are the same over both directories, so a search can resolve in each and nothing but a flag could say which was meant. It would also make a liar of `resolve_ticket`, which explains a ticket search that *names* a campaign. Under `campaign` the object is settled by the command, as it is for `set`, `show` and `ls`
|
||||
- **Still no `--owner` and still no `--clear`.** No `--owner`, because nothing writes a campaign's Owner today and giving `set` one would settle by accident whether `chown` grows a campaign. No `--clear`, which 32e98ab settled rather than deferred: a codename is replaced rather than emptied, and emptying the description of a container six tickets are filed against is not a thing anybody has asked for, so the only spellings left would be `Clearable` on a campaign, whose variants are a ticket's fields, or a second enum with one variant in it. `campaign_set_offers_no_owner_and_no_clear` pins both
|
||||
- **An empty `--description ""` is a paragraph break here too, and the refusal for an all-blank value names no flag.** Every prose argument in the tool reads a blank value that way, `add`, `set` and `tags --annotation` alike, so a campaign reading it as *empty the section* would be the one exception. With no `--clear` to point at, the refusal says a campaign's description has no cleared form instead of naming a flag that does not exist. `replaced_items` is where the check lives, shared with `set`, and the way out is the caller's argument for exactly that reason
|
||||
- **`SECTION_ORDER` needs no campaign variant, and that is what the one-section file proves.** A campaign holds Description and Metadata where a ticket holds four sections and Metadata. Every consumer of the list looks for the headings that follow, *filtered by what is actually in the file*, so a campaign's description anchors against `## Metadata` — which is where `campaign_body` writes it. `the_description_is_edited_in_place_in_a_file_with_one_section` pins that no section a campaign does not have gets inserted to anchor against
|
||||
- **A campaign whose Description heading is gone is refused, not given the section back.** No `ensure_section` on this path: every campaign the tool has ever filed carries the heading, so an insertion here would be reachable only from a hand-edited file, which is the opposite of the Relations case, where `add` writes nothing and the insertion is the only path there is. The refusal therefore names the section and **not** the object — "There is no description section to write to" — because both a ticket and a campaign reach `replace_section_body` now. `write_then_replace` still carries the noun, where the message is about a file
|
||||
- **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
|
||||
@@ -392,7 +398,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
### Color and Output
|
||||
- Use `color_text()` for coloured output — it respects `should_use_colors()` (terminal detection), and `paint()` is the same with the decision passed in
|
||||
- **`color_text()` is for the CLI's own printing only. Anything reachable from `content_trim` takes the decision as an argument and calls `paint()`**, because the board renders with colour off and an escape sequence in a ratatui paragraph is drawn as literal bytes. `nothing_the_body_renders_asks_the_terminal_for_the_colour_decision` scans this file and fails on a new caller; the allowlist is `ambiguous`, which builds a failed-search message for stderr
|
||||
- A function that takes an `enabled` flag must use it all the way down. `colorize_bold` honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function
|
||||
- A function that takes an `enabled` flag must use it all the way down. `colorize_inline` honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function
|
||||
- **A test that asserts an absence has to be paired with one that asserts the presence.** The guard for this, an assert that the detail view holds no escape byte, could not fail: a test binary has no tty, so `should_use_colors()` was false and the leaking branch was never taken. The pair is now `content_trim(.., false)` has no escape and `content_trim(.., true)` still colours, which pins the flag as the only thing that decides
|
||||
- **The palette is the `Color` enum, not a string.** `Color::ansi()` gives the CLI its SGR sequence and `From<Color> for ratatui::style::Color` gives the TUI its equivalent, so a colour that exists for one renderer and not the other is a compile error. The stringly-typed version needed a test for exactly that, and a missing entry silently produced an empty prefix, which is how `magenta` came to be undefined
|
||||
- Reset color with `\x1b[0m` after colored text
|
||||
@@ -409,6 +415,7 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Priority ramp → brightred (1), red (2), orange (3), cyan (4), grey (5). Green is deliberately absent: it means title
|
||||
- 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
|
||||
- Markdown link → cyan, markers and url kept. Not a new meaning for the colour: the plan numbers, the criterion numbers and the `relates to` mark are already cyan inside a rendered body, and a link is the same kind of thing, a pointer the reader may follow rather than a value. The url is not hidden behind the text the way a renderer would hide it, because `show` prints to a terminal worklane cannot assume will make it clickable, and a link whose target cannot be read is worse than a long line
|
||||
- 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
|
||||
@@ -420,7 +427,8 @@ and this file is for what someone changing worklane's own code needs.
|
||||
- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows
|
||||
|
||||
### Code Organization
|
||||
- Colorization functions (`colorize_ordered`, `colorize_bold`, `content_trim_colored`) handle markdown formatting. `colorize_line` is gone: it was a `pub` alias for `colorize_bold` with one caller, and the only thing it added was asking the terminal
|
||||
- Colorization functions (`colorize_ordered`, `colorize_inline`, `content_trim_colored`) handle markdown formatting. `colorize_line` is gone: it was a `pub` alias for the bold pass with one caller, and the only thing it added was asking the terminal
|
||||
- **`colorize_inline` walks the line once for both inline markers**, `**bold**` and `[text](url)`, rather than running one pass over the output of the other. A second pass would be scanning text that already holds escape sequences, and `\x1b[36m` carries an opening bracket, so the link scan would take the escape for markup. The source is the only string in which either marker means what it says. It was `colorize_bold` while links lived in a branch of their own in `content_parts`; that branch is gone, which is also what gives the criteria text and the metadata `Other` rows their links, since those already went through this function
|
||||
- `show` renders the Metadata section as a two column table via `render_metadata_table`, not line by line. Column width is measured on the raw field names in characters and padding is applied before anything is styled: measuring a coloured string counts its escapes towards its width. `paint()` is `color_text()` with the colour decision passed in, which is what lets a test render both ways in one process
|
||||
- The title is printed once, by `cmd_show`. `content_trim_colored` skips the `# ` heading in the file content
|
||||
- Rules under headings are measured on the displayed name in characters, never on the raw line or in bytes
|
||||
@@ -448,12 +456,12 @@ and this file is for what someone changing worklane's own code needs.
|
||||
### Version Bumps
|
||||
- Before every commit, decide whether the change warrants a version bump in `Cargo.toml`
|
||||
- Always ask the user to confirm the bump and its kind before making it — never bump silently, and never skip the question because the answer looks obvious
|
||||
- **`make patch`, `make minor` and `make major` do the mechanics**, run after the commit is in: each bumps `Cargo.toml` and the `worklane` entry in `Cargo.lock`, appends `, and bump to <version>` to the commit's subject, folds the bump into that commit, and tags it. Bumping by hand is how a version comes to be left untagged, which is what the one action is for. It refuses on a dirty tree, on an already-tagged `HEAD` and on a `HEAD` that is already pushed, since each of those makes the amend lose work, orphan a tag or need a force push
|
||||
- Pre-1.0, so: patch for fixes and internal changes, minor for a new command, flag or changed output, major only for a deliberate 1.0
|
||||
- **Changed output means the CLI's output.** That is the surface scripts and agents read, so a changed listing, message or exit code is a minor. A change to what the board draws is a patch however visible it is, since nothing consumes the frame. See The Board View
|
||||
- **Settling output that shipped one version ago is a patch**, not a second minor. 0.15.1 changed the relation mark 0.15.0 had just introduced, and 0.15.2 added the status mark beside it: the minor was the arrival of a marked relations block, and settling what it marks belongs to that. Three minors in an hour would tell anyone reading the tags that there were three features
|
||||
- No bump for docs-only, tests-only or `--fixup` commits
|
||||
- When one body of work spans several commits, bump once on the final commit rather than on each
|
||||
- Bump `Cargo.toml` and the `worklane` entry in `Cargo.lock` together, in the commit that carries the bump
|
||||
- Every bump gets a matching annotated tag, `v<version>`, on the bump commit — a bumped version is never left untagged
|
||||
- Tag locally only; never push a tag unless asked
|
||||
- `worklane --version` reports the crate version alongside the build sha, so the bump is what makes one release distinguishable from another
|
||||
|
||||
Generated
+1
-1
@@ -1503,7 +1503,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.26.4"
|
||||
version = "0.27.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.26.4"
|
||||
version = "0.27.2"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
# Release helpers.
|
||||
#
|
||||
# `make patch|minor|major` bumps the version in Cargo.toml and Cargo.lock, folds
|
||||
# that bump into the last commit, and tags it. Everything is one action so a
|
||||
# release cannot end up half-done: no version bump left untagged, no tag without
|
||||
# a bump.
|
||||
|
||||
.PHONY: help patch minor major version release install
|
||||
|
||||
help:
|
||||
@echo "make patch bump $(CURRENT) -> next patch, amend into HEAD, tag"
|
||||
@echo "make minor bump $(CURRENT) -> next minor, amend into HEAD, tag"
|
||||
@echo "make major bump $(CURRENT) -> next major, amend into HEAD, tag"
|
||||
@echo "make version print the current version"
|
||||
@echo "make install cargo install --path . && worklane install-skill"
|
||||
|
||||
# Read from the [package] table of Cargo.toml, which is the version the binary
|
||||
# reports through `--version`, so it is the single source of truth. The name is
|
||||
# what finds this crate's own entry in Cargo.lock.
|
||||
PACKAGE = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^name *= *"/{print $$2; exit}' Cargo.toml)
|
||||
CURRENT = $(shell awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p && /^version *= *"/{print $$2; exit}' Cargo.toml)
|
||||
|
||||
# 1 appends ", and bump to <version>" to the amended commit's subject; empty
|
||||
# leaves the message alone.
|
||||
AMEND_SUBJECT = 1
|
||||
|
||||
version:
|
||||
@echo $(CURRENT)
|
||||
|
||||
patch: BUMP = patch
|
||||
minor: BUMP = minor
|
||||
major: BUMP = major
|
||||
patch minor major: release
|
||||
|
||||
# A release rewrites the last commit, so refuse anything that would make that
|
||||
# rewrite lose work or orphan a tag.
|
||||
release:
|
||||
@set -e; \
|
||||
if ! git rev-parse -q --verify HEAD >/dev/null 2>&1; then \
|
||||
echo "error: no commits yet, so there is no commit to fold a version bump into. Commit first." >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if [ -n "$$(git status --porcelain)" ]; then \
|
||||
echo "error: working tree is dirty. Commit or stash first, and decide whether that work belongs in this version:" >&2; \
|
||||
git status --short >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if [ -n "$$(git tag --points-at HEAD)" ]; then \
|
||||
echo "error: HEAD is already tagged $$(git tag --points-at HEAD | paste -sd' '). Amending it would leave that tag on an orphaned commit. Commit something first." >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if upstream=$$(git rev-parse --abbrev-ref --symbolic-full-name '@{u}' 2>/dev/null) && \
|
||||
git merge-base --is-ancestor HEAD "$$upstream" 2>/dev/null; then \
|
||||
echo "error: HEAD is already pushed to $$upstream. Amending it would need a force push. Commit something first." >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
current="$(CURRENT)"; \
|
||||
if [ -z "$$current" ]; then echo "error: no version found in the [package] table of Cargo.toml" >&2; exit 1; fi; \
|
||||
new=$$(echo "$$current" | awk -F. -v kind=$(BUMP) '{ \
|
||||
if (NF != 3) exit 1; \
|
||||
if (kind == "patch") printf "%d.%d.%d\n", $$1, $$2, $$3 + 1; \
|
||||
else if (kind == "minor") printf "%d.%d.0\n", $$1, $$2 + 1; \
|
||||
else printf "%d.0.0\n", $$1 + 1 }'); \
|
||||
if [ -z "$$new" ]; then echo "error: cannot bump version '$$current': expected major.minor.patch" >&2; exit 1; fi; \
|
||||
if git rev-parse -q --verify "refs/tags/v$$new" >/dev/null; then \
|
||||
echo "error: tag v$$new already exists" >&2; exit 1; \
|
||||
fi; \
|
||||
awk -v v="$$new" '/^\[package\]/{p=1} /^\[/ && !/^\[package\]/{p=0} p && /^version *= *"/{sub(/"[^"]*"/, "\"" v "\"")} {print}' Cargo.toml > Cargo.toml.bump; \
|
||||
mv Cargo.toml.bump Cargo.toml; \
|
||||
git add Cargo.toml; \
|
||||
if [ -f Cargo.lock ] && git ls-files --error-unmatch Cargo.lock >/dev/null 2>&1; then \
|
||||
awk -v v="$$new" -v pkg="$(PACKAGE)" '$$0 == "name = \"" pkg "\""{f=1} f && /^version = "/{sub(/"[^"]*"/, "\"" v "\""); f=0} {print}' Cargo.lock > Cargo.lock.bump; \
|
||||
mv Cargo.lock.bump Cargo.lock; \
|
||||
git add Cargo.lock; \
|
||||
fi; \
|
||||
if [ -n "$(AMEND_SUBJECT)" ]; then \
|
||||
subject=$$(git log -1 --format=%s | sed -E 's/, and bump to [0-9]+\.[0-9]+\.[0-9]+$$//'); \
|
||||
body=$$(git log -1 --format=%b); \
|
||||
if [ -n "$$body" ]; then \
|
||||
git commit --quiet --amend -m "$$subject, and bump to $$new" -m "$$body"; \
|
||||
else \
|
||||
git commit --quiet --amend -m "$$subject, and bump to $$new"; \
|
||||
fi; \
|
||||
else \
|
||||
git commit --quiet --amend --no-edit; \
|
||||
fi; \
|
||||
git tag -a "v$$new" -m "v$$new"; \
|
||||
echo "$$current -> $$new, tagged v$$new on $$(git rev-parse --short HEAD) ($$(git log -1 --format=%s))"
|
||||
|
||||
install:
|
||||
cargo install --path .
|
||||
worklane install-skill
|
||||
@@ -19,7 +19,8 @@ Worklane is a local Kanban flow for agentic software development.
|
||||
| `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. Replacing a codename the campaign already has needs `--force`, since that is the word it is referred to by everywhere; setting the one it already has is a no-op either way. No `--description`: replacing prose without an `append` to add a paragraph is half a pair |
|
||||
| `worklane campaign set <campaign>` | Replaces `--title`, which renames the file keeping the uuid, `--description` and `--codename`. At least one required. The way a campaign filed before codenames existed gets one, and the way a description filed with a typo in it gets fixed. Replacing a codename the campaign already has needs `--force`, since that is the word it is referred to by everywhere; setting the one it already has is a no-op either way. A description needs no `--force`: it is prose written to be revised. No `--clear` and no `--owner` |
|
||||
| `worklane campaign append <campaign>` | Adds a paragraph to a campaign's description with `--description`, which is required. The other half of `campaign set --description`, so adding a line to a description does not mean retyping the rest of it. Repeat the flag for more lines within the one paragraph. Its own subcommand rather than the top-level `append`, which resolves a ticket |
|
||||
| `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 |
|
||||
@@ -77,3 +78,20 @@ Whether a truncated pipe reports 141 or 0 depends on the size of the output, not
|
||||
the command. A pipe holds 64 KiB, so a listing that fits lands in the buffer whole
|
||||
and the writer never learns the reader left, giving 0. Only output past that gets far
|
||||
enough to be cut off. Either way nothing is printed to stderr.
|
||||
|
||||
## Releasing
|
||||
|
||||
```sh
|
||||
make patch # 0.27.1 -> next patch
|
||||
make minor # 0.27.1 -> next minor
|
||||
make major # 0.27.1 -> next major
|
||||
```
|
||||
|
||||
Each bumps `Cargo.toml` and `Cargo.lock`, folds that bump into the last commit, and tags it
|
||||
`v<version>`. One action, so no bump is left untagged and no tag lands without a bump. In this repo
|
||||
it also appends `, and bump to <version>` to the commit's subject, the way the release commits
|
||||
before it read.
|
||||
|
||||
It refuses to run when the working tree is dirty, when `HEAD` is already tagged, or when `HEAD` is
|
||||
already pushed. The first asks you to decide whether that work belongs in the version; the other two
|
||||
mean the amend would orphan a tag or need a force push.
|
||||
|
||||
+8
-1
@@ -168,7 +168,8 @@ fields; a goal is a campaign.
|
||||
worklane campaign ls
|
||||
worklane campaign show v1
|
||||
worklane campaign add --title "..." --codename v1 --description "..."
|
||||
worklane campaign set v1 --title "..." # or --codename, on one already filed
|
||||
worklane campaign set v1 --title "..." # or --description or --codename, on one already filed
|
||||
worklane campaign append v1 -d "..." # add a paragraph to the description
|
||||
worklane assign v1 1b78a24
|
||||
```
|
||||
|
||||
@@ -194,6 +195,12 @@ tui is usable on a narrow terminal" is a campaign. "The tui tickets" is a tag.
|
||||
- **Do not propose renaming a codename a campaign already has.** It is what the campaign is
|
||||
called on every card in it and at the command line, so changing it is churn dressed as
|
||||
grooming. `campaign set` refuses it without `--force` for that reason.
|
||||
- **A campaign's description is editable, so a wrong one is a fix rather than a refiling.**
|
||||
A container whose description no longer describes what its members are for is worth
|
||||
pointing out: it is the line every one of those tickets was filed against. `campaign set
|
||||
--description` replaces it and `campaign append --description` adds to it, so neither
|
||||
needs the campaign refiled and its members reassigned. Adding to it is the usual answer;
|
||||
replacing prose to add a sentence to it is how the rest of it gets lost.
|
||||
|
||||
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.
|
||||
|
||||
+12
-4
@@ -211,7 +211,8 @@ worklane campaign add --title "First public release" --codename v1 \
|
||||
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 # its body, then its members by status
|
||||
worklane campaign set v1 --title "..." # replace the title or the codename
|
||||
worklane campaign set v1 --title "..." # replace the title, description or codename
|
||||
worklane campaign append v1 -d "..." # add a paragraph to the description
|
||||
worklane assign v1 1b78a24 # put a ticket in it
|
||||
worklane ls --campaign v1 # only that campaign's tickets
|
||||
```
|
||||
@@ -226,9 +227,16 @@ existed needs. **Replacing a codename it already has needs `--force`**: that wor
|
||||
the campaign is referred to on the board and at the command line, so changing it is a
|
||||
decision rather than a correction. Setting the one it already has is a no-op either way.
|
||||
|
||||
`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.
|
||||
`campaign set` and `campaign append` are the only ways to change a campaign after it is
|
||||
filed. `set` replaces the title, the description or the codename; `append` adds a paragraph
|
||||
to the description, which is what to use when the description is right and only incomplete,
|
||||
since replacing prose to add a sentence to it is how the rest of it gets lost. An empty
|
||||
`--description ""` between two values is a paragraph break, exactly as it is for a ticket,
|
||||
and a call whose every value is blank is refused: a campaign's description cannot be
|
||||
emptied. There is still no way to change a campaign's owner.
|
||||
|
||||
`append` here is `campaign append` and not the top-level `append`, which takes a ticket. The
|
||||
two objects are addressed the same way, so the command is what says which one is meant.
|
||||
|
||||
`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
|
||||
|
||||
+63
-16
@@ -358,10 +358,18 @@ pub enum Command {
|
||||
/// No `mv`: a campaign has no status to move it to, its state is derived from its
|
||||
/// 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.
|
||||
/// `set` and `append` arrive together, 32e98ab, because for a prose section they are a
|
||||
/// pair: a way to replace a description with no way to add a paragraph to one is the half
|
||||
/// that is easy to reach for and wrong, since replacing a description to add a sentence is
|
||||
/// how the rest of it gets lost. The two scalars have no append form at all, which is the
|
||||
/// same line `append` already draws for a ticket.
|
||||
///
|
||||
/// **`append` is a campaign's own subcommand and not the top-level `append`.** That one
|
||||
/// resolves a ticket, and its positional would then name either object: `resolve_in`'s tiers
|
||||
/// are the same over both directories, so a search can resolve in each and nothing but a
|
||||
/// flag could say which was meant. It would also make a liar of `resolve_ticket`, which
|
||||
/// explains a ticket search that names a campaign. Under `campaign` the object is settled by
|
||||
/// the command, the way it is for `set`, `show` and `ls`.
|
||||
#[derive(clap::Subcommand)]
|
||||
pub enum CampaignCommand {
|
||||
/// File a new campaign
|
||||
@@ -369,11 +377,19 @@ pub enum CampaignCommand {
|
||||
|
||||
/// 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.
|
||||
/// The only way to change a campaign's title or codename 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),
|
||||
|
||||
/// Add a paragraph to a campaign's description
|
||||
///
|
||||
/// The other half of `campaign set --description`, and the half that keeps what is
|
||||
/// already written: a description is the sentence a whole campaign's members are filed
|
||||
/// against, so adding a line to it must not mean retyping it.
|
||||
Append(CampaignAppendArgs),
|
||||
|
||||
/// List campaigns with their member counts
|
||||
Ls {
|
||||
/// Print one campaign per line as its id and title, tab separated, for a script
|
||||
@@ -394,25 +410,30 @@ 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`].
|
||||
/// What can be replaced on a campaign that is already filed: everything it holds but its
|
||||
/// owner.
|
||||
///
|
||||
/// 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.
|
||||
/// No `--clear`, which is 32e98ab's decision and not a deferral. A codename is replaced
|
||||
/// rather than emptied, and a campaign's one prose section has no cleared form worth
|
||||
/// reaching: emptying the description of a container six tickets are filed against is not a
|
||||
/// thing anybody has asked for, and the only ways to spell it would be to put [`Clearable`]
|
||||
/// on a campaign, whose variants are a ticket's fields, or to invent a second enum with one
|
||||
/// variant in it. So an empty `--description ""` stays a paragraph break here exactly as it
|
||||
/// is everywhere else, and the refusal for an all-blank value says there is nowhere to go
|
||||
/// back to rather than naming a flag that does not exist.
|
||||
///
|
||||
/// `--force` guards the codename and nothing else. A campaign that already has one is
|
||||
/// referred to by it: it is on every card in the campaign, it is what resolves it at the
|
||||
/// command line, and it is very likely in somebody's shell history. Replacing that silently
|
||||
/// is the same mistake overwriting an edited skill document would be, which is what
|
||||
/// `install-skill --force` exists for. A title needs no guard, since a campaign always has
|
||||
/// one and replacing it is the whole point of the flag.
|
||||
/// one and replacing it is the whole point of the flag. Neither does a description: it is
|
||||
/// prose written to be revised, the same reason `tags set --annotation` has no guard, and a
|
||||
/// guard in front of the command's whole purpose is worse than no command.
|
||||
///
|
||||
/// 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`].
|
||||
@@ -421,7 +442,7 @@ pub enum CampaignCommand {
|
||||
clap::ArgGroup::new("campaign_set_fields")
|
||||
.required(true)
|
||||
.multiple(true)
|
||||
.args(["title", "codename"])
|
||||
.args(["title", "description", "codename"])
|
||||
))]
|
||||
pub struct CampaignSetArgs {
|
||||
/// Campaign UUID, title, filename or codename
|
||||
@@ -431,6 +452,13 @@ pub struct CampaignSetArgs {
|
||||
#[arg(short, long, allow_hyphen_values = PROSE, value_parser = non_empty)]
|
||||
pub title: Option<String>,
|
||||
|
||||
/// Replace the description. Repeat the flag for more lines, empty for a paragraph break
|
||||
///
|
||||
/// The whole section, so a paragraph added to it is `campaign append --description`
|
||||
/// rather than the description retyped
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<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
|
||||
@@ -449,6 +477,25 @@ pub struct CampaignSetArgs {
|
||||
pub force: bool,
|
||||
}
|
||||
|
||||
/// What can be added to a campaign that is already filed: a paragraph of its description.
|
||||
///
|
||||
/// One field, so it is `required` rather than a group of one, which is the longer way to say
|
||||
/// the same thing and the shape [`TagSetArgs`] already takes. A bare
|
||||
/// `worklane campaign append <c>` is therefore a usage error rather than a silent no-op.
|
||||
///
|
||||
/// No `--title` and no `--codename`, because appending to a scalar has no meaning. That is
|
||||
/// the line `append` already draws for a ticket, where the title is absent for the same
|
||||
/// reason.
|
||||
#[derive(clap::Args)]
|
||||
pub struct CampaignAppendArgs {
|
||||
/// Campaign UUID, title, filename or codename
|
||||
pub campaign: String,
|
||||
|
||||
/// Add a paragraph to the description. Repeat the flag for more lines within it
|
||||
#[arg(short, long, required = true, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<String>,
|
||||
}
|
||||
|
||||
/// What a campaign holds: a title, a description and an owner.
|
||||
///
|
||||
/// Deliberately narrower than [`AddArgs`]. There are no acceptance criteria, because a
|
||||
|
||||
+14
-6
@@ -50,11 +50,16 @@ pub const CAMPAIGN_COMMANDS: [&str; 1] = ["assign"];
|
||||
|
||||
/// Nested subcommands whose first argument is a campaign, as `parent child`.
|
||||
///
|
||||
/// `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")];
|
||||
/// `campaign show`, `campaign set` and `campaign append`, 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); 3] = [
|
||||
("campaign", "show"),
|
||||
("campaign", "set"),
|
||||
("campaign", "append"),
|
||||
];
|
||||
|
||||
/// Options whose value is a campaign.
|
||||
pub const CAMPAIGN_FLAGS: [&str; 1] = ["campaign"];
|
||||
@@ -374,7 +379,10 @@ mod tests {
|
||||
|
||||
// A guard on the walker itself: if it stopped finding arguments, every assertion
|
||||
// above would pass by never running.
|
||||
assert_eq!(seen, 4, "expected assign, campaign show, campaign set and ls --campaign");
|
||||
assert_eq!(
|
||||
seen, 5,
|
||||
"expected assign, campaign show, campaign set, campaign append and ls --campaign"
|
||||
);
|
||||
}
|
||||
|
||||
/// Commands whose tag positional names a tag that does not exist yet.
|
||||
|
||||
+89
-17
@@ -7,8 +7,8 @@ use std::path::Path;
|
||||
|
||||
use crate::campaign::*;
|
||||
use crate::command::{
|
||||
AddArgs, AppendArgs, CampaignAddArgs, CampaignSetArgs, CheckArgs, ChownArgs, LsArgs,
|
||||
RelateArgs, SetArgs, TagAddArgs, TagSetArgs,
|
||||
AddArgs, AppendArgs, CampaignAddArgs, CampaignAppendArgs, CampaignSetArgs, CheckArgs,
|
||||
ChownArgs, LsArgs, RelateArgs, SetArgs, TagAddArgs, TagSetArgs,
|
||||
};
|
||||
use crate::install;
|
||||
use crate::tag::{TAGS_FILE, TagIndex, tags_path};
|
||||
@@ -784,6 +784,42 @@ fn section_args<'a>(
|
||||
]
|
||||
}
|
||||
|
||||
/// The lines a caller's values amount to, or the refusal an all-blank call earns.
|
||||
///
|
||||
/// An empty value is a paragraph break, so a call whose values are *every one* blank asked
|
||||
/// for nothing, and writing an empty section is not what it meant. Shared by `set` and
|
||||
/// `campaign set` because the rule is the section's rather than the object's.
|
||||
///
|
||||
/// `instead` is the way out, and it is the caller's because the callers differ: a ticket's
|
||||
/// section is emptied with `--clear <field>`, and a campaign's description has no cleared
|
||||
/// form at all, per [`CampaignSetArgs`].
|
||||
fn replaced_items(section: &Section, values: &[String], instead: &str) -> Result<Vec<String>> {
|
||||
let items = section.normalise(values);
|
||||
if items.is_empty() {
|
||||
return Err(anyhow!(
|
||||
"An empty value is a paragraph break, not a way to empty the {}: {}",
|
||||
section.label,
|
||||
instead
|
||||
));
|
||||
}
|
||||
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
/// The same for `append`, which has no way out to name: appending nothing was never a way
|
||||
/// to empty anything, so the message says only that there was nothing to add.
|
||||
fn appended_items(section: &Section, values: &[String]) -> Result<Vec<String>> {
|
||||
let items = section.normalise(values);
|
||||
if items.is_empty() {
|
||||
return Err(anyhow!(
|
||||
"Nothing to append to the {}: every value given was blank",
|
||||
section.label
|
||||
));
|
||||
}
|
||||
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
/// Write the ticket back, renaming the file when a new title changes its slug.
|
||||
///
|
||||
/// The content goes down first and the rename second, the same order and for the same
|
||||
@@ -917,14 +953,8 @@ pub fn cmd_set(args: &SetArgs, start: &Path) -> Result<()> {
|
||||
continue;
|
||||
}
|
||||
|
||||
let items = section.normalise(values);
|
||||
if items.is_empty() {
|
||||
return Err(anyhow!(
|
||||
"An empty value is a paragraph break, not a way to empty the {}: use --clear {}",
|
||||
section.label,
|
||||
section.clear.map_or("", Clearable::name)
|
||||
));
|
||||
}
|
||||
let clear = format!("use --clear {}", section.clear.map_or("", Clearable::name));
|
||||
let items = replaced_items(section, values, &clear)?;
|
||||
|
||||
let next = set_section_body(&content, section, &items)?;
|
||||
apply(&mut content, &mut changed, section.label, next);
|
||||
@@ -1031,13 +1061,7 @@ pub fn cmd_append(args: &AppendArgs, start: &Path) -> Result<()> {
|
||||
continue;
|
||||
}
|
||||
|
||||
let items = section.normalise(values);
|
||||
if items.is_empty() {
|
||||
return Err(anyhow!(
|
||||
"Nothing to append to the {}: every value given was blank",
|
||||
section.label
|
||||
));
|
||||
}
|
||||
let items = appended_items(section, values)?;
|
||||
|
||||
content = append_section_body(&content, section, &items)?;
|
||||
changed.push(section.label);
|
||||
@@ -1409,6 +1433,18 @@ pub fn cmd_tag_set(args: &TagSetArgs, start: &Path) -> Result<()> {
|
||||
/// No-op detection compares the whole file, the way `set` and `chown` do, so setting a
|
||||
/// codename a campaign already carries writes nothing. That is a no-op and not a refusal:
|
||||
/// `--force` is about overwriting a *different* word, and there is nothing to overwrite.
|
||||
///
|
||||
/// **The description goes through `set_section_body` and the `DESCRIPTION` entry**, the
|
||||
/// section table `cmd_set` and `campaign_body` already read, so what a campaign's one prose
|
||||
/// section *is* stays decided in one place. A second definition scoped to campaigns would
|
||||
/// drift on the spelling of the heading, which is the drift `campaign_body` was written
|
||||
/// against.
|
||||
///
|
||||
/// A campaign whose Description heading is gone is refused by that call rather than given
|
||||
/// the section back through `ensure_section`. Every campaign the tool has ever filed carries
|
||||
/// the heading, so an insertion path here would be reachable only from a hand-edited file:
|
||||
/// that is the opposite of the Relations case, where `add` writes nothing and the insertion
|
||||
/// is the only path there is.
|
||||
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)?;
|
||||
@@ -1436,6 +1472,16 @@ pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
|
||||
apply(&mut content, &mut changed, "title", next);
|
||||
}
|
||||
|
||||
if !args.description.is_empty() {
|
||||
let items = replaced_items(
|
||||
&DESCRIPTION,
|
||||
&args.description,
|
||||
"a campaign's description has no cleared form",
|
||||
)?;
|
||||
let next = set_section_body(&content, &DESCRIPTION, &items)?;
|
||||
apply(&mut content, &mut changed, DESCRIPTION.label, 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);
|
||||
@@ -1453,6 +1499,32 @@ pub fn cmd_campaign_set(args: &CampaignSetArgs, start: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add a paragraph to a campaign's description.
|
||||
///
|
||||
/// The other half of `campaign set --description`, and `cmd_append` for a campaign: the same
|
||||
/// `append_section_body` and the same `DESCRIPTION` entry, so a paragraph lands under a
|
||||
/// campaign's description the way it lands under a ticket's, blank line and all. A campaign
|
||||
/// filed with no description holds the placeholder, and that is replaced rather than
|
||||
/// followed, which is `append_section_body`'s rule and not a case handled here.
|
||||
///
|
||||
/// No whole-file comparison, unlike `set`: every value blank is refused above, so there is
|
||||
/// nothing left that appends nothing. `cmd_append` says it the same way.
|
||||
///
|
||||
/// One section, so there is no loop and no list to report: what changed is the description
|
||||
/// or the call failed.
|
||||
pub fn cmd_campaign_append(args: &CampaignAppendArgs, start: &Path) -> Result<()> {
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let campaign = resolve_campaign(&args.campaign, &worklane_dir)?;
|
||||
|
||||
let items = appended_items(&DESCRIPTION, &args.description)?;
|
||||
let content = append_section_body(&campaign.content, &DESCRIPTION, &items)?;
|
||||
|
||||
save_campaign(&worklane_dir, &campaign.uuid, &campaign.title, None, &content)?;
|
||||
|
||||
report(&[DESCRIPTION.label], &campaign.title, "Appended to");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Show a campaign, then its members grouped by status.
|
||||
///
|
||||
/// Every status is shown, done included, unlike `ls`, which leaves done out of its
|
||||
|
||||
+6
-1
@@ -73,6 +73,7 @@ fn main() -> Result<()> {
|
||||
cmd_campaign_ls(&worklane_dir, ids)
|
||||
}
|
||||
CampaignCommand::Set(args) => cmd_campaign_set(&args, &start),
|
||||
CampaignCommand::Append(args) => cmd_campaign_append(&args, &start),
|
||||
CampaignCommand::Show { campaign } => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_campaign_show(&campaign, &worklane_dir)
|
||||
@@ -247,7 +248,11 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
|
||||
// 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(),
|
||||
KeyCode::Char('c') => board.open_picker(tui::PickerKind::Campaign, screen),
|
||||
// The other axis the board is cut along, and the one `ls --tag` has
|
||||
// answered since 2f3796e. Free of every other binding: `tab` is its own
|
||||
// key code, not this letter.
|
||||
KeyCode::Char('t') => board.open_picker(tui::PickerKind::Tag, screen),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -163,6 +163,16 @@ impl TagIndex {
|
||||
self.tags.keys().map(String::as_str)
|
||||
}
|
||||
|
||||
/// What a tag means, whole, or `None` for a tag the file does not declare.
|
||||
///
|
||||
/// The raw section, paragraphs and all, where [`Self::summary`] is the one line a
|
||||
/// listing has room for. `Some("")` is a tag declared with nothing said about it, which
|
||||
/// the caller has to tell apart from `None`: the board draws the two in different
|
||||
/// sections.
|
||||
pub fn annotation(&self, tag: &str) -> Option<&str> {
|
||||
self.tags.get(tag).map(String::as_str)
|
||||
}
|
||||
|
||||
/// The opening line of what a tag means, or `None` for a tag the file does not declare.
|
||||
///
|
||||
/// The cut to one line lives here rather than on the parse, the way
|
||||
|
||||
+997
-156
File diff suppressed because it is too large
Load Diff
+130
-47
@@ -841,31 +841,13 @@ pub fn content_parts(content: &str, colored: bool, resolved: &Resolved) -> Vec<B
|
||||
result.push(' ');
|
||||
result.push_str(&paint(if checked { "[x]" } else { "[ ]" }, Color::Grey, colored));
|
||||
result.push(' ');
|
||||
result.push_str(&colorize_bold(text, colored));
|
||||
result.push_str(&colorize_inline(text, colored));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
|
||||
// Standard markdown link colorization in cyan
|
||||
if line.contains("[")
|
||||
&& line.contains("(")
|
||||
&& line.contains("]")
|
||||
&& let Some(start) = line.find("[")
|
||||
{
|
||||
let bracket_text = &line[start..];
|
||||
if let Some(end_bracket) = bracket_text.find("](") {
|
||||
let link_start = start + end_bracket + 1;
|
||||
if let Some(end) = line[link_start..].find(']') {
|
||||
let absolute_end = link_start + end + 1;
|
||||
result.push_str(&paint(&line[start..absolute_end], Color::Cyan, colored));
|
||||
result.push('\n');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Regular content - colorize **bold** in magenta
|
||||
result.push_str(&colorize_bold(line, colored));
|
||||
// Regular content, with its inline markup coloured in place.
|
||||
result.push_str(&colorize_inline(line, colored));
|
||||
result.push('\n');
|
||||
}
|
||||
|
||||
@@ -1042,7 +1024,7 @@ fn render_metadata_table(lines: &[&str], colored: bool, campaign: &str) -> Strin
|
||||
// The decision this row is rendered under, not the one the terminal
|
||||
// would give: `colorize_line` asked `should_use_colors()` here, which is
|
||||
// how escapes reached the board's detail view.
|
||||
MetadataRow::Other(text) => result.push_str(&colorize_bold(text, colored)),
|
||||
MetadataRow::Other(text) => result.push_str(&colorize_inline(text, colored)),
|
||||
}
|
||||
result.push('\n');
|
||||
}
|
||||
@@ -1077,13 +1059,20 @@ pub fn is_unknown_value(value: &str) -> bool {
|
||||
trimmed == NONE || trimmed == NOT_SET
|
||||
}
|
||||
|
||||
/// Replace `**bold**` with colour, or leave the line exactly as it is.
|
||||
/// Replace `**bold**` with colour and paint `[text](url)`, or leave the line exactly
|
||||
/// as it is.
|
||||
///
|
||||
/// Taking `enabled` rather than asking makes both paths testable, and the
|
||||
/// disabled path matters: stripping the markers when there is no colour to
|
||||
/// replace them with loses the emphasis altogether, which is what happens to
|
||||
/// every piped `show` and to everything the opencode tools read.
|
||||
fn colorize_bold(line: &str, enabled: bool) -> String {
|
||||
///
|
||||
/// One walk for both markers rather than two passes. A pass over the output of
|
||||
/// another would be scanning text that already holds escape sequences, and `\x1b[36m`
|
||||
/// carries an opening bracket: a link scan run afterwards would take the escape for
|
||||
/// markup. Walking the source once is the only place either marker can be recognised
|
||||
/// for what it is.
|
||||
fn colorize_inline(line: &str, enabled: bool) -> String {
|
||||
if !enabled {
|
||||
return line.to_string();
|
||||
}
|
||||
@@ -1093,27 +1082,34 @@ fn colorize_bold(line: &str, enabled: bool) -> String {
|
||||
let mut i = 0;
|
||||
|
||||
while i < chars.len() {
|
||||
if !is_delimiter(&chars, i) {
|
||||
result.push(chars[i]);
|
||||
i += 1;
|
||||
// Unterminated markup falls through to the push below, one character at a
|
||||
// time, so the rest of the line survives as the literal text it is. The old
|
||||
// link branch pushed its match and dropped everything around it.
|
||||
if is_delimiter(&chars, i)
|
||||
&& let Some(close) = (i + 2..chars.len()).find(|&at| is_delimiter(&chars, at))
|
||||
{
|
||||
let bold: String = chars[i + 2..close].iter().collect();
|
||||
// `enabled`, not `should_use_colors()`. Asking again here made the
|
||||
// flag a lie: the early return above respected it and this did not.
|
||||
result.push_str(&paint(&bold, Color::Magenta, enabled));
|
||||
i = close + 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
match (i + 2..chars.len()).find(|&at| is_delimiter(&chars, at)) {
|
||||
Some(close) => {
|
||||
let bold: String = chars[i + 2..close].iter().collect();
|
||||
// `enabled`, not `should_use_colors()`. Asking again here made the
|
||||
// flag a lie: the early return above respected it and this did not.
|
||||
result.push_str(&paint(&bold, Color::Magenta, enabled));
|
||||
i = close + 2;
|
||||
}
|
||||
// Unterminated: the rest is literal. The old scan walked off the end
|
||||
// here and dropped the final character.
|
||||
None => {
|
||||
result.extend(&chars[i..]);
|
||||
return result;
|
||||
}
|
||||
if chars[i] == '['
|
||||
&& let Some(end) = link_end(&chars, i)
|
||||
{
|
||||
// Markers and url kept, unlike the bold pair. The url is content: a
|
||||
// reader of `show` wants to see where the link goes, and the terminal
|
||||
// that would make it clickable is not something worklane can count on.
|
||||
let link: String = chars[i..end].iter().collect();
|
||||
result.push_str(&paint(&link, Color::Cyan, enabled));
|
||||
i = end;
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(chars[i]);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
result
|
||||
@@ -1123,6 +1119,22 @@ fn is_delimiter(chars: &[char], at: usize) -> bool {
|
||||
chars.get(at) == Some(&'*') && chars.get(at + 1) == Some(&'*')
|
||||
}
|
||||
|
||||
/// The index one past the end of the `[text](url)` opening at `open`, or nothing when
|
||||
/// the line does not close one.
|
||||
///
|
||||
/// The closing parenthesis is what ends a link. The old branch looked for a second
|
||||
/// square bracket there, which a well-formed link does not have, so the whole branch
|
||||
/// fired only on text that was not a link at all.
|
||||
fn link_end(chars: &[char], open: usize) -> Option<usize> {
|
||||
let close_text = (open + 1..chars.len()).find(|&at| chars[at] == ']')?;
|
||||
if chars.get(close_text + 1) != Some(&'(') {
|
||||
return None;
|
||||
}
|
||||
|
||||
let close_url = (close_text + 2..chars.len()).find(|&at| chars[at] == ')')?;
|
||||
Some(close_url + 1)
|
||||
}
|
||||
|
||||
pub const METADATA_HEADING: &str = "## Metadata";
|
||||
|
||||
fn is_metadata_heading(line: &str) -> bool {
|
||||
@@ -1843,6 +1855,12 @@ pub fn clear_section_body(content: &str, section: &Section) -> Result<String> {
|
||||
}
|
||||
|
||||
/// The line surgery both of the above are, given a body that is already rendered.
|
||||
///
|
||||
/// The refusal names the section and not the file it is missing from, because both a ticket
|
||||
/// and a campaign reach here: `campaign set --description` writes a campaign's one prose
|
||||
/// section through this, so "Ticket has no description section" would be wrong half the
|
||||
/// time. `write_then_replace` carries the noun instead, where a message about a *file* is
|
||||
/// worth spelling.
|
||||
fn replace_section_body(
|
||||
content: &str,
|
||||
section: &Section,
|
||||
@@ -1850,7 +1868,7 @@ fn replace_section_body(
|
||||
) -> Result<String> {
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let body = section_body(&lines, section.heading)
|
||||
.ok_or_else(|| anyhow!("Ticket has no {} section", section.label))?;
|
||||
.ok_or_else(|| anyhow!("There is no {} section to write to", section.label))?;
|
||||
|
||||
let mut out: Vec<String> = lines[..body.start].iter().map(|l| l.to_string()).collect();
|
||||
out.extend(body_lines);
|
||||
@@ -1871,7 +1889,7 @@ fn replace_section_body(
|
||||
pub fn append_section_body(content: &str, section: &Section, items: &[String]) -> Result<String> {
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let body = section_body(&lines, section.heading)
|
||||
.ok_or_else(|| anyhow!("Ticket has no {} section", section.label))?;
|
||||
.ok_or_else(|| anyhow!("There is no {} section to write to", section.label))?;
|
||||
|
||||
let at = body_content_end(&lines, &body);
|
||||
let existing: Vec<&&str> = lines[body.start..at]
|
||||
@@ -4553,12 +4571,12 @@ mod tests {
|
||||
#[test]
|
||||
fn bold_markers_survive_when_colour_is_off() {
|
||||
let line = "Some **bold** text";
|
||||
assert_eq!(colorize_bold(line, false), line);
|
||||
assert_eq!(colorize_inline(line, false), line);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bold_markers_are_replaced_when_colour_is_on() {
|
||||
let out = colorize_bold("Some **bold** text", true);
|
||||
let out = colorize_inline("Some **bold** text", true);
|
||||
assert!(out.contains("bold"), "was {out:?}");
|
||||
assert!(!out.contains("**"), "markers left behind in {out:?}");
|
||||
}
|
||||
@@ -4567,17 +4585,82 @@ mod tests {
|
||||
#[test]
|
||||
fn an_unterminated_marker_keeps_the_whole_line() {
|
||||
for line in ["a **bold", "**", "***", "trailing **"] {
|
||||
assert_eq!(colorize_bold(line, true), line, "for {line:?}");
|
||||
assert_eq!(colorize_inline(line, true), line, "for {line:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn several_bold_runs_on_one_line_all_survive() {
|
||||
let out = colorize_bold("**one** and **two** and rest", true);
|
||||
let out = colorize_inline("**one** and **two** and rest", true);
|
||||
assert!(out.contains("one") && out.contains("two") && out.ends_with("and rest"));
|
||||
assert!(!out.contains("**"), "was {out:?}");
|
||||
}
|
||||
|
||||
/// The old branch pushed the span it matched and dropped the rest of the line.
|
||||
#[test]
|
||||
fn a_link_keeps_the_text_on_either_side_of_it() {
|
||||
let out = colorize_inline("see [the docs](https://x.test/y) for more", true);
|
||||
|
||||
assert!(out.starts_with("see "), "was {out:?}");
|
||||
assert!(out.ends_with(" for more"), "was {out:?}");
|
||||
assert!(out.contains("[the docs](https://x.test/y)"), "was {out:?}");
|
||||
assert!(out.contains(Color::Cyan.ansi()), "not painted in {out:?}");
|
||||
}
|
||||
|
||||
/// With no colour to carry it, the markup is the markup.
|
||||
#[test]
|
||||
fn a_link_survives_unchanged_when_colour_is_off() {
|
||||
let line = "see [the docs](https://x.test/y) for more";
|
||||
assert_eq!(colorize_inline(line, false), line);
|
||||
}
|
||||
|
||||
/// The closing parenthesis ends a link. Looking for a second square bracket there,
|
||||
/// as the old branch did, meant it fired on anything but a link.
|
||||
#[test]
|
||||
fn text_that_is_not_a_closed_link_is_left_alone() {
|
||||
for line in [
|
||||
"a [label] and (a note)",
|
||||
"unterminated [text](http://x.test",
|
||||
"[a][b] reference style",
|
||||
"bare [",
|
||||
] {
|
||||
assert_eq!(colorize_inline(line, true), line, "for {line:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn several_links_on_one_line_all_survive() {
|
||||
let out = colorize_inline("[a](1) then [b](2) then end", true);
|
||||
|
||||
assert!(out.contains("[a](1)") && out.contains("[b](2)"), "was {out:?}");
|
||||
assert!(out.ends_with(" then end"), "was {out:?}");
|
||||
}
|
||||
|
||||
/// Both markers are recognised in the same walk, so a line does not have to pick
|
||||
/// which of the two it gets.
|
||||
#[test]
|
||||
fn bold_and_a_link_on_one_line_are_both_coloured() {
|
||||
let out = colorize_inline("**note**: read [this](http://x.test) first", true);
|
||||
|
||||
assert!(!out.contains("**"), "markers left behind in {out:?}");
|
||||
assert!(out.contains("[this](http://x.test)"), "was {out:?}");
|
||||
assert!(out.contains(Color::Magenta.ansi()), "no bold in {out:?}");
|
||||
assert!(out.contains(Color::Cyan.ansi()), "no link in {out:?}");
|
||||
assert!(out.ends_with(" first"), "was {out:?}");
|
||||
}
|
||||
|
||||
/// End to end: the body a `show` prints keeps every word of a line with a link.
|
||||
#[test]
|
||||
fn a_body_line_with_a_link_keeps_all_of_its_text() {
|
||||
let content = "# T\n\n## Description\n\nbefore [docs](http://x.test/a) after\n";
|
||||
let rendered = content_trim(content, false, &Resolved::default());
|
||||
|
||||
assert!(
|
||||
rendered.ends_with("before [docs](http://x.test/a) after\n"),
|
||||
"{rendered:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn short_id_shortens_a_full_uuid() {
|
||||
assert_eq!(short_id("c230d2c6-d78a-44a5-8f5f-88fb28f84493"), "c230d2c");
|
||||
|
||||
+445
-5
@@ -1129,11 +1129,13 @@ fn an_unknown_campaign_is_refused_and_nothing_is_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.
|
||||
/// `--description` arrived with `campaign append`, 32e98ab, because for a prose section the
|
||||
/// two are a pair. What is still deliberately absent is what this pins: no `--owner`, which
|
||||
/// would settle by accident whether `chown` grows a campaign, and no `--clear`, because a
|
||||
/// campaign's description has no cleared form and `Clearable`'s variants are a ticket's
|
||||
/// fields.
|
||||
#[test]
|
||||
fn campaign_set_offers_no_description_and_no_owner() {
|
||||
fn campaign_set_offers_no_owner_and_no_clear() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
@@ -1142,7 +1144,7 @@ fn campaign_set_offers_no_description_and_no_owner() {
|
||||
|
||||
assert!(help.contains("--codename"), "{help}");
|
||||
assert!(help.contains("--title"), "{help}");
|
||||
assert!(!help.contains("--description"), "{help}");
|
||||
assert!(help.contains("--description"), "{help}");
|
||||
assert!(!help.contains("--owner"), "{help}");
|
||||
assert!(!help.contains("--clear"), "{help}");
|
||||
}
|
||||
@@ -1263,3 +1265,441 @@ fn the_title_is_replaced_without_force() {
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(campaign_file(&worklane, CAMP_A).starts_with("# First public release\n"));
|
||||
}
|
||||
|
||||
// ---------------------------------------------- campaign set --description --
|
||||
|
||||
/// The point of 32e98ab: the description a campaign was filed with is no longer the one it
|
||||
/// keeps. `create_campaign` writes prose, so this is a replacement rather than a first line.
|
||||
#[test]
|
||||
fn campaign_set_replaces_the_description() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"set",
|
||||
"v1 release",
|
||||
"--description",
|
||||
"What the tag has to hold.",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("Updated description"), "{}", stdout(&out));
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.contains("What the tag has to hold."), "{content}");
|
||||
assert!(
|
||||
!content.contains("What has to ship together."),
|
||||
"the old description survived: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// An empty value between two others is the paragraph break, the rule every prose argument
|
||||
/// in the tool follows: `add --description`, `set --description` and `tags --annotation`.
|
||||
#[test]
|
||||
fn an_empty_value_is_a_paragraph_break_in_a_campaigns_description() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"set",
|
||||
"v1 release",
|
||||
"-d",
|
||||
"The tag itself.",
|
||||
"-d",
|
||||
"",
|
||||
"-d",
|
||||
"And what blocks it.",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.contains("The tag itself.\n\nAnd what blocks it."), "{content}");
|
||||
}
|
||||
|
||||
/// And an all-blank value is refused rather than emptying the section. The refusal names no
|
||||
/// flag, because there is none: a campaign's description has no cleared form, which is the
|
||||
/// `Clearable` question 32e98ab settled rather than deferred.
|
||||
#[test]
|
||||
fn an_all_blank_description_is_refused_and_names_no_clear_flag() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
|
||||
let out = run(&temp, &["campaign", "set", "v1 release", "-d", "", "-d", " "]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
let said = stderr(&out);
|
||||
assert!(said.contains("An empty value is a paragraph break"), "{said}");
|
||||
assert!(said.contains("no cleared form"), "{said}");
|
||||
assert!(!said.contains("--clear"), "it named a flag that does not exist: {said}");
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was written");
|
||||
}
|
||||
|
||||
/// The whole-file comparison `set`, `chown` and the codename already use, so a description
|
||||
/// replaced with the one it already holds writes nothing.
|
||||
#[test]
|
||||
fn setting_the_description_a_campaign_already_has_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"set",
|
||||
"v1 release",
|
||||
"-d",
|
||||
"What has to ship together.",
|
||||
],
|
||||
);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
/// Three fields in one call, since the group is `multiple` and the description is in it.
|
||||
#[test]
|
||||
fn campaign_set_takes_the_title_the_description_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",
|
||||
"-d",
|
||||
"What the tag has to hold.",
|
||||
"-c",
|
||||
"v1",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("title, description, codename"), "{}", stdout(&out));
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.starts_with("# First public release\n"), "{content}");
|
||||
assert!(content.contains("What the tag has to hold."), "{content}");
|
||||
assert!(content.contains("- **Codename**: v1"), "{content}");
|
||||
}
|
||||
|
||||
/// A refused codename takes the description down with it, the way it already takes the
|
||||
/// title: checked before any edit is applied, so a call writes all of what it asked for or
|
||||
/// none of it.
|
||||
#[test]
|
||||
fn a_refused_codename_takes_the_description_down_with_it() {
|
||||
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",
|
||||
"-d",
|
||||
"Rewritten anyway.",
|
||||
"-c",
|
||||
"beaver",
|
||||
],
|
||||
);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the description went through");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------- campaign append --
|
||||
|
||||
/// The other half of the pair, and the reason `set --description` is not a flag on its own:
|
||||
/// adding a line to a description must not mean retyping the rest of it.
|
||||
#[test]
|
||||
fn campaign_append_adds_a_paragraph_without_replacing_the_description() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"append",
|
||||
"v1 release",
|
||||
"-d",
|
||||
"And what is out of scope.",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("Appended to description"), "{}", stdout(&out));
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
// The paragraph lands after the one that was there, with the blank line between them
|
||||
// that makes it a paragraph rather than a run-on.
|
||||
assert!(
|
||||
content.contains("What has to ship together.\n\nAnd what is out of scope.\n"),
|
||||
"{content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Several values in one call are lines *within* the paragraph, not several paragraphs. The
|
||||
/// same reading `append --description` gives a ticket, since it is the same section entry.
|
||||
#[test]
|
||||
fn the_values_of_one_append_are_lines_within_the_paragraph() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"append",
|
||||
"v1 release",
|
||||
"-d",
|
||||
"Out of scope:",
|
||||
"-d",
|
||||
"the installer.",
|
||||
],
|
||||
);
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.contains("Out of scope:\nthe installer.\n"), "{content}");
|
||||
}
|
||||
|
||||
/// A campaign filed with no description holds the placeholder, and appending replaces it
|
||||
/// rather than following it: the alternative reads `_No description provided._` above the
|
||||
/// description. `append_section_body`'s rule, so nothing here handles the case.
|
||||
#[test]
|
||||
fn appending_to_an_empty_description_replaces_the_placeholder() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "add", "--title", "No prose yet"]);
|
||||
|
||||
let uuid = {
|
||||
let names = campaigns(&worklane);
|
||||
let name = names
|
||||
.iter()
|
||||
.find(|name| name.ends_with("_no-prose-yet.md"))
|
||||
.expect("the campaign was not filed");
|
||||
name.split('_').next().unwrap().to_string()
|
||||
};
|
||||
assert!(
|
||||
campaign_file(&worklane, &uuid).contains("_No description provided._"),
|
||||
"the placeholder is not what add writes any more"
|
||||
);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"append",
|
||||
"No prose yet",
|
||||
"-d",
|
||||
"The first thing said.",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let content = campaign_file(&worklane, &uuid);
|
||||
assert!(content.contains("The first thing said."), "{content}");
|
||||
assert!(
|
||||
!content.contains("_No description provided._"),
|
||||
"the placeholder is still above the description: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Every value blank is refused rather than writing nothing quietly, the answer `append`
|
||||
/// gives a ticket, in the same words: appending nothing was never a way to empty anything,
|
||||
/// so there is no flag to name.
|
||||
#[test]
|
||||
fn an_all_blank_append_is_refused() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
|
||||
let out = run(&temp, &["campaign", "append", "v1 release", "-d", " "]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
assert!(stderr(&out).contains("Nothing to append"), "{}", stderr(&out));
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "the file was written");
|
||||
}
|
||||
|
||||
/// A bare `campaign append <campaign>` is a usage error rather than a silent no-op, the way
|
||||
/// a bare `campaign set` is. `--description` is `required` rather than a group of one.
|
||||
#[test]
|
||||
fn campaign_append_with_no_description_is_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
|
||||
let out = run(&temp, &["campaign", "append", "v1 release"]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(2), "{}", stderr(&out));
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "something was written");
|
||||
}
|
||||
|
||||
/// Appending to a scalar has no meaning, which is the line `append` already draws for a
|
||||
/// ticket: no `--title` there and none here, and no `--codename` either.
|
||||
#[test]
|
||||
fn campaign_append_offers_only_the_description() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "append", "--help"]);
|
||||
let help = stdout(&out);
|
||||
|
||||
assert!(help.contains("--description"), "{help}");
|
||||
assert!(!help.contains("--title"), "{help}");
|
||||
assert!(!help.contains("--codename"), "{help}");
|
||||
assert!(!help.contains("--force"), "{help}");
|
||||
}
|
||||
|
||||
/// A campaign is addressed here by the same tiers everything else takes, codename included,
|
||||
/// because it goes through `resolve_campaign` rather than a lookup of its own.
|
||||
#[test]
|
||||
fn campaign_append_resolves_the_campaign_by_its_codename() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "beaver"]);
|
||||
|
||||
let out = run(&temp, &["campaign", "append", "beaver", "-d", "One more thing."]);
|
||||
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(
|
||||
campaign_file(&worklane, CAMP_A).contains("One more thing."),
|
||||
"{}",
|
||||
campaign_file(&worklane, CAMP_A)
|
||||
);
|
||||
}
|
||||
|
||||
/// An unknown campaign leaves every campaign alone, the answer `campaign set` and `assign`
|
||||
/// already give.
|
||||
#[test]
|
||||
fn campaign_append_refuses_an_unknown_campaign() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = campaign_file(&worklane, CAMP_A);
|
||||
|
||||
let out = run(&temp, &["campaign", "append", "nothing-by-that-name", "-d", "Text."]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
assert!(stderr(&out).contains("No campaign found"), "{}", stderr(&out));
|
||||
assert_eq!(campaign_file(&worklane, CAMP_A), before, "something was written");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------ the shared machinery --
|
||||
|
||||
/// A campaign has one section where a ticket has four, and the section table in `util.rs` is
|
||||
/// what both go through. So the surgery has to land against `## Metadata`, which is the only
|
||||
/// heading that follows a campaign's description, and leave everything outside the body
|
||||
/// alone: a handwritten section, the owner, and the codename in its place.
|
||||
#[test]
|
||||
fn the_description_is_edited_in_place_in_a_file_with_one_section() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
run(&temp, &["campaign", "set", "v1 release", "-c", "v1"]);
|
||||
|
||||
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", "-d", "Replaced."]);
|
||||
run(&temp, &["campaign", "append", "v1", "-d", "Added."]);
|
||||
|
||||
let content = campaign_file(&worklane, CAMP_A);
|
||||
assert!(content.contains("## Description\nReplaced.\n\nAdded.\n"), "{content}");
|
||||
// Nothing outside the body moved: the section that follows it, the handwritten one
|
||||
// between them, and the fields under it.
|
||||
assert!(content.contains("## Notes\nA handwritten note."), "{content}");
|
||||
assert!(content.contains("- **Codename**: v1"), "{content}");
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
assert!(!content.contains("**Status**"), "a status was invented: {content}");
|
||||
// And no section a campaign does not have was inserted to anchor against.
|
||||
assert!(!content.contains("## Acceptance Criteria"), "{content}");
|
||||
assert!(!content.contains("## Implementation Plan"), "{content}");
|
||||
}
|
||||
|
||||
/// The heading is the one in the section table, so `campaign set --description` reaches the
|
||||
/// section `campaign_body` wrote and `campaign show` prints. A second spelling scoped to
|
||||
/// campaigns is what this would catch.
|
||||
#[test]
|
||||
fn the_description_a_campaign_is_filed_with_is_the_one_set_replaces() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"Filed with prose",
|
||||
"--description",
|
||||
"As filed.",
|
||||
],
|
||||
);
|
||||
run(&temp, &["campaign", "set", "Filed with prose", "-d", "As replaced."]);
|
||||
|
||||
let out = run(&temp, &["campaign", "show", "Filed with prose"]);
|
||||
let shown = stdout(&out);
|
||||
assert!(shown.contains("As replaced."), "{shown}");
|
||||
assert!(!shown.contains("As filed."), "{shown}");
|
||||
// One Description heading in the file, not a second one written beside it.
|
||||
let names = campaigns(&worklane);
|
||||
let name = names
|
||||
.iter()
|
||||
.find(|name| name.ends_with("_filed-with-prose.md"))
|
||||
.expect("not filed");
|
||||
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
|
||||
assert_eq!(content.matches("## Description").count(), 1, "{content}");
|
||||
}
|
||||
|
||||
/// A campaign file with no Description heading is refused rather than given one back. Every
|
||||
/// campaign the tool files carries the heading, so an insertion path here would be reachable
|
||||
/// only from a hand-edited file, which is the opposite of the Relations case. The message
|
||||
/// names the section and not the object, because both a ticket and a campaign reach it.
|
||||
#[test]
|
||||
fn a_campaign_with_no_description_section_is_refused() {
|
||||
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("## Description\nWhat has to ship together.\n\n", ""),
|
||||
)
|
||||
.unwrap();
|
||||
let before = fs::read_to_string(&path).unwrap();
|
||||
|
||||
for args in [
|
||||
["campaign", "set", "v1 release", "-d", "Text."],
|
||||
["campaign", "append", "v1 release", "-d", "Text."],
|
||||
] {
|
||||
let out = run(&temp, &args);
|
||||
assert_eq!(out.status.code(), Some(1), "{}", stderr(&out));
|
||||
let said = stderr(&out);
|
||||
assert!(said.contains("no description section"), "{said}");
|
||||
assert!(!said.contains("Ticket"), "a campaign was called a ticket: {said}");
|
||||
assert_eq!(fs::read_to_string(&path).unwrap(), before, "the file was written");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user