Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
175c1d016d | ||
|
|
139c9b012f | ||
|
|
373ba519b3 | ||
|
|
88918b2f8a | ||
|
|
6784d80324 | ||
|
|
ae3ee1bb9e | ||
|
|
5ae9c7fe00 | ||
|
|
ce32b42ae4 | ||
|
|
ece201e3ab | ||
|
|
c437d87e9e | ||
|
|
0ce3fdb246 | ||
|
|
37dbd722e0 | ||
|
|
4502de7ee3 | ||
|
|
a16169ce8c | ||
|
|
3d6a74bc53 | ||
|
|
7a0dd625ce | ||
|
|
8d8ae8abfe | ||
|
|
d5fb22cfd8 | ||
|
|
2c0a99f7c4 | ||
|
|
91bbc19c32 | ||
|
|
5b0bac9c2d | ||
|
|
41a65f95b2 | ||
|
|
3085b0226f | ||
|
|
b56b31d2d9 | ||
|
|
e6fe51e31e | ||
|
|
c606b5ba43 | ||
|
|
90b313952b | ||
|
|
7240fc263b | ||
|
|
580e3cf7f0 | ||
|
|
2298d3373a | ||
|
|
8013c2b74d | ||
|
|
6178d7bd3d | ||
|
|
f740e42d1c | ||
|
|
220789efea | ||
|
|
c1137f29cf | ||
|
|
77bf2d9e2a | ||
|
|
78831f1a39 | ||
|
|
bbb1568a0f | ||
|
|
3810e442c6 | ||
|
|
6c43e62a4b | ||
|
|
39ee86e308 | ||
|
|
5a7cfeb849 | ||
|
|
e20396ce6b | ||
|
|
f5204f6d8b | ||
|
|
b28ddb9210 |
@@ -35,12 +35,15 @@ Add a new ticket to the backlog.
|
||||
- `--acceptance` (or `-a`): Acceptance criteria (repeat flag for each criterium)
|
||||
- `--plan` (or `-p`): Implementation plan steps (repeat flag for each step)
|
||||
- `--tags` (or `-g`): Tags (comma-separated)
|
||||
- `--due` (or `--due`): Due date in YYYY-MM-DD format
|
||||
- `--due`: Due date in YYYY-MM-DD format. No short form
|
||||
- `--owner` (or `-o`): Owner name
|
||||
- `--priority`: Priority level, 1 (most urgent) to 5 (least). Unset if omitted
|
||||
- `--priority`: Priority level, 1 (most urgent) to 5 (least). Unset if omitted. No short form
|
||||
|
||||
Tags are `-g`, not `-t`: `-t` is the title, and passing it twice is an error. Each
|
||||
plan step needs its own `-p`, since a bare value after one is not a second step.
|
||||
|
||||
```bash
|
||||
worklane add -t "Implement login" -d "Add user login page" -t login,auth -p "Design UI" "Build backend" "Write tests" --due 2026-06-01 --owner "ilya"
|
||||
worklane add -t "Implement login" -d "Add user login page" -g login,auth -p "Design UI" -p "Build backend" -p "Write tests" --due 2026-06-01 --owner "ilya"
|
||||
```
|
||||
|
||||
When there's multiple acceptance criteria, add each using a separate `--acceptance` or `-a` flag.
|
||||
@@ -79,7 +82,7 @@ worklane show "ticket title or uuid"
|
||||
Move a ticket between statuses.
|
||||
|
||||
**Positional arguments:**
|
||||
- `<id>`: Ticket UUID (8+ characters) or title
|
||||
- `<id>`: Ticket UUID prefix (4+ characters) or title
|
||||
|
||||
**Required options:**
|
||||
- `--status <target>`: Target status (`backlog`, `committed`, `reviewing`, `done`)
|
||||
@@ -98,12 +101,88 @@ worklane mv a1b2c3d4 --status committed # Move by UUID prefix
|
||||
worklane mv "My Ticket" --status done -f # Move by title with force
|
||||
```
|
||||
|
||||
### `worklane set`
|
||||
|
||||
Replace fields on an existing ticket. Only the fields given are touched; ticked
|
||||
criteria and handwritten sections are left alone. At least one field is required.
|
||||
|
||||
**Positional arguments:**
|
||||
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
|
||||
|
||||
**Options:** `--title`, `--description` (or `-d`), `--acceptance` (or `-a`), `--plan`
|
||||
(or `-p`), `--tags` (or `-g`), `--due`, `--priority`
|
||||
|
||||
Owner is not settable here, and neither is status: `chown` owns owner and `mv` owns
|
||||
status. Changing the title renames the file, keeping the UUID.
|
||||
|
||||
```bash
|
||||
worklane set a1b2c3d4 --priority 1
|
||||
worklane set a1b2c3d4 --title "A clearer title" --due 2026-12-31
|
||||
worklane set a1b2c3d4 -a "First criterium" -a "Second criterium"
|
||||
```
|
||||
|
||||
### `worklane append`
|
||||
|
||||
Add to a section without replacing what is there. The description gains a new
|
||||
paragraph; criteria and steps go on the end of their lists, steps numbered on from
|
||||
the last. At least one section is required.
|
||||
|
||||
**Positional arguments:**
|
||||
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
|
||||
|
||||
**Options:** `--description` (or `-d`), `--acceptance` (or `-a`), `--plan` (or `-p`)
|
||||
|
||||
```bash
|
||||
worklane append a1b2c3d4 -d "A paragraph amending the description."
|
||||
worklane append a1b2c3d4 -a "One more criterium"
|
||||
worklane append a1b2c3d4 -p "A later step"
|
||||
```
|
||||
|
||||
### `worklane chown`
|
||||
|
||||
Set the owner of a ticket. The only command that writes the Owner field: `set` does
|
||||
not offer it.
|
||||
|
||||
**Positional arguments:**
|
||||
- `<user>`: The new owner. Free text, checked against nothing
|
||||
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
|
||||
|
||||
The user comes first and the ticket second, after Unix `chown`. That is the one
|
||||
command here that does not start with the ticket, so mind the order: swap the two and
|
||||
the call fails, because the username has to resolve as a ticket. An owner set to the
|
||||
value it already holds is reported unchanged and nothing is written.
|
||||
|
||||
```bash
|
||||
worklane chown alice a1b2c3d4
|
||||
worklane chown "Ansho Rei" "A clearer title"
|
||||
```
|
||||
|
||||
### `worklane check` and `worklane uncheck`
|
||||
|
||||
Tick or untick a single acceptance criterion. Every other criterion keeps its state,
|
||||
and handwritten lines in the section are left alone.
|
||||
|
||||
**Positional arguments:**
|
||||
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
|
||||
- `[criterion]`: The number as shown by `worklane show`, or a substring of its text
|
||||
|
||||
Omit the criterion and the numbered criteria are listed and the number asked for. With
|
||||
no terminal, as when driving the CLI from a tool, the same list comes back as an error
|
||||
instead, so re-run with the number. A substring matching more than one criterion is an
|
||||
error listing the matches with their real numbers.
|
||||
|
||||
```bash
|
||||
worklane check a1b2c3d4 2
|
||||
worklane check a1b2c3d4 "renames the file"
|
||||
worklane uncheck a1b2c3d4 2
|
||||
```
|
||||
|
||||
### `worklane comment`
|
||||
|
||||
Add a comment to a ticket.
|
||||
|
||||
**Positional arguments:**
|
||||
- `<ticket>`: Ticket UUID (8+ characters) or title
|
||||
- `<ticket>`: Ticket UUID prefix (4+ characters) or title
|
||||
- `<body>`: Comment text
|
||||
|
||||
Comments are stored as timestamped markdown files in `.worklane/comments/<ticket-uuid>/` and include the git author and timestamp.
|
||||
@@ -116,10 +195,29 @@ worklane comment "My Ticket" "Needs changes to the UI"
|
||||
worklane comment a1b2c3d4 "LGTM, approved"
|
||||
```
|
||||
|
||||
## Workflow
|
||||
## Working a ticket
|
||||
|
||||
1. Use `worklane add` to create tickets with all relevant details
|
||||
2. Use `worklane ls [status]` to view tickets by status
|
||||
3. Use `worklane show <id>` to view full ticket details
|
||||
4. Use `worklane mv <id> --status <target>` to move tickets through the workflow
|
||||
5. Use `worklane comment <ticket> <body>` to add notes to tickets
|
||||
Move the ticket as you work it, not afterwards. The board should say what is happening
|
||||
now, not only what already landed.
|
||||
|
||||
1. `worklane show <id>` to read it
|
||||
2. **`worklane mv <id> --status committed` before writing any code.** This is what marks
|
||||
the ticket as being worked on, so it belongs at the start
|
||||
3. Do the work. `worklane check <id> <n>` as each criterion is met
|
||||
4. `worklane comment <id> <body>` with anything worth recording: a decision, a rejected
|
||||
acceptance criterion, something the ticket got wrong
|
||||
5. **`worklane mv <id> --status reviewing` once it is done and the tests pass**
|
||||
|
||||
Only one stage forward is allowed at a time, so a ticket left in `backlog` until the end
|
||||
cannot go straight to `reviewing`. It has to be walked through `committed` anyway, which
|
||||
makes moving it up front the same two commands in a more useful order.
|
||||
|
||||
## Commands
|
||||
|
||||
- `worklane add` creates tickets with all relevant details
|
||||
- `worklane ls [status]` views tickets by status
|
||||
- `worklane show <id>` views full ticket details
|
||||
- `worklane mv <id> --status <target>` moves tickets through the workflow
|
||||
- `worklane set <ticket>` corrects a field, `worklane append <ticket>` adds to a section
|
||||
- `worklane check <ticket> <n>` ticks a criterion as it is met
|
||||
- `worklane comment <ticket> <body>` adds notes to tickets
|
||||
|
||||
+267
-24
@@ -38,6 +38,39 @@ async function run(cmd: string[], context: ToolContext): Promise<string> {
|
||||
return stdout.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Description lines as worklane wants them, one --description value per line,
|
||||
* blank ones included.
|
||||
*
|
||||
* cmd_add joins the values with a single newline, so an empty value is how a
|
||||
* paragraph break is spelled. Dropping the blanks here, which is what the old
|
||||
* filter(Boolean) did, collapsed every multi paragraph description into a single
|
||||
* paragraph, against this tool's own instruction to separate paragraphs with
|
||||
* newlines.
|
||||
*
|
||||
* Only the ends are trimmed, and only trailing whitespace within a line. Leading
|
||||
* whitespace is content: it is what makes a nested markdown list or an indented
|
||||
* block survive the trip.
|
||||
*/
|
||||
function descriptionLines(text: string): string[] {
|
||||
const lines = text.split("\n").map((line: string) => line.trimEnd());
|
||||
|
||||
let start = 0;
|
||||
let end = lines.length;
|
||||
while (start < end && lines[start] === "") start++;
|
||||
while (end > start && lines[end - 1] === "") end--;
|
||||
|
||||
return lines.slice(start, end);
|
||||
}
|
||||
|
||||
/** One value per non-empty line, for the arguments that hold a list of items. */
|
||||
function itemLines(text: string): string[] {
|
||||
return text
|
||||
.split("\n")
|
||||
.map((line: string) => line.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
export const init = tool({
|
||||
description:
|
||||
"Initialize worklane in the current project. Creates the .worklane/ directory with backlog, committed, reviewing, and done subdirectories.",
|
||||
@@ -54,28 +87,37 @@ export const init = tool({
|
||||
export const add = tool({
|
||||
description:
|
||||
"Add a new ticket to the worklane backlog. Requires a title. Description, acceptance criteria, and plan each support multiple lines (one item per line). Tags are comma-separated.",
|
||||
// Title is the only required field. Every other flag is left off entirely when
|
||||
// the field is omitted, so an unmarked schema only forced the model to invent a
|
||||
// value for fields it had nothing to say about.
|
||||
args: {
|
||||
title: tool.schema
|
||||
.string()
|
||||
.describe("Ticket title (required)"),
|
||||
description: tool.schema
|
||||
.string()
|
||||
.describe("Description text. Use newlines between paragraphs."),
|
||||
.describe("Description text. Use newlines between paragraphs.")
|
||||
.optional(),
|
||||
acceptance: tool.schema
|
||||
.string()
|
||||
.describe("Acceptance criteria, one per line. Put each criterium on its own line."),
|
||||
.describe("Acceptance criteria, one per line. Put each criterium on its own line.")
|
||||
.optional(),
|
||||
plan: tool.schema
|
||||
.string()
|
||||
.describe("Implementation plan steps, one per line. Put each step on its own line."),
|
||||
.describe("Implementation plan steps, one per line. Put each step on its own line.")
|
||||
.optional(),
|
||||
tags: tool.schema
|
||||
.string()
|
||||
.describe("Comma-separated tags, e.g. 'bug,frontend,urgent'"),
|
||||
.describe("Comma-separated tags, e.g. 'bug,frontend,urgent'")
|
||||
.optional(),
|
||||
due: tool.schema
|
||||
.string()
|
||||
.describe("Due date in YYYY-MM-DD format"),
|
||||
.describe("Due date in YYYY-MM-DD format")
|
||||
.optional(),
|
||||
owner: tool.schema
|
||||
.string()
|
||||
.describe("Ticket owner name. If omitted, defaults to the git user."),
|
||||
.describe("Ticket owner name. If omitted, defaults to the git user.")
|
||||
.optional(),
|
||||
priority: tool.schema
|
||||
.string()
|
||||
.describe("Priority level, 1 (most urgent) to 5 (least). Left unset if omitted.")
|
||||
@@ -87,27 +129,21 @@ export const add = tool({
|
||||
}
|
||||
const cmd: string[] = ["add", "--title", args.title];
|
||||
if (args.description) {
|
||||
args.description
|
||||
.split("\n")
|
||||
.map((l: string) => l.trim())
|
||||
.filter(Boolean)
|
||||
.forEach((line: string) => cmd.push("--description", line));
|
||||
descriptionLines(args.description).forEach((line: string) =>
|
||||
cmd.push("--description", line),
|
||||
);
|
||||
}
|
||||
|
||||
// Blanks are dropped from these two on purpose: each value is one criterium or
|
||||
// one step, so an empty line between them is spacing rather than content.
|
||||
if (args.acceptance) {
|
||||
args.acceptance
|
||||
.split("\n")
|
||||
.map((l: string) => l.trim())
|
||||
.filter(Boolean)
|
||||
.forEach((line: string) => cmd.push("--acceptance", line));
|
||||
itemLines(args.acceptance).forEach((line: string) =>
|
||||
cmd.push("--acceptance", line),
|
||||
);
|
||||
}
|
||||
|
||||
if (args.plan) {
|
||||
args.plan
|
||||
.split("\n")
|
||||
.map((l: string) => l.trim())
|
||||
.filter(Boolean)
|
||||
.forEach((line: string) => cmd.push("--plan", line));
|
||||
itemLines(args.plan).forEach((line: string) => cmd.push("--plan", line));
|
||||
}
|
||||
|
||||
if (args.tags) cmd.push("--tags", args.tags);
|
||||
@@ -155,7 +191,7 @@ export const show = tool({
|
||||
args: {
|
||||
id: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
},
|
||||
async execute(args: Record<string, any>, context: ToolContext) {
|
||||
if (!args.id) {
|
||||
@@ -175,7 +211,7 @@ export const mv = tool({
|
||||
args: {
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
status: tool.schema
|
||||
.enum(["backlog", "committed", "reviewing", "done"])
|
||||
.describe("Target status (required)"),
|
||||
@@ -207,7 +243,7 @@ export const comment = tool({
|
||||
args: {
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
body: tool.schema
|
||||
.string()
|
||||
.describe("Comment body text (required). Supports markdown formatting and multiple paragraphs separated by newlines."),
|
||||
@@ -234,3 +270,210 @@ export const comment = tool({
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const set = tool({
|
||||
description:
|
||||
"Replace fields on an existing worklane ticket. Only the fields given are touched; everything else in the file, including ticked criteria and handwritten sections, is left alone. Owner is not settable here, use chown. Status is not settable here, use mv. To add to a section instead of replacing it, use append.",
|
||||
args: {
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
title: tool.schema
|
||||
.string()
|
||||
.describe("New title. The file is renamed to match, keeping the UUID.")
|
||||
.optional(),
|
||||
description: tool.schema
|
||||
.string()
|
||||
.describe("New description, replacing the whole section. Use newlines between paragraphs.")
|
||||
.optional(),
|
||||
acceptance: tool.schema
|
||||
.string()
|
||||
.describe("New acceptance criteria, one per line, replacing the whole list.")
|
||||
.optional(),
|
||||
plan: tool.schema
|
||||
.string()
|
||||
.describe("New implementation plan steps, one per line, replacing the whole list.")
|
||||
.optional(),
|
||||
tags: tool.schema
|
||||
.string()
|
||||
.describe("New comma-separated tags, replacing the existing ones.")
|
||||
.optional(),
|
||||
due: tool.schema
|
||||
.string()
|
||||
.describe("New due date in YYYY-MM-DD format")
|
||||
.optional(),
|
||||
priority: tool.schema
|
||||
.string()
|
||||
.describe("New priority level, 1 (most urgent) to 5 (least)")
|
||||
.optional(),
|
||||
},
|
||||
async execute(args: Record<string, any>, context: ToolContext) {
|
||||
if (!args.ticket) {
|
||||
return "Error setting fields: ticket is required";
|
||||
}
|
||||
|
||||
const cmd: string[] = ["set", args.ticket];
|
||||
if (args.title) cmd.push("--title", args.title);
|
||||
if (args.description) {
|
||||
descriptionLines(args.description).forEach((line: string) =>
|
||||
cmd.push("--description", line),
|
||||
);
|
||||
}
|
||||
if (args.acceptance) {
|
||||
itemLines(args.acceptance).forEach((line: string) =>
|
||||
cmd.push("--acceptance", line),
|
||||
);
|
||||
}
|
||||
if (args.plan) {
|
||||
itemLines(args.plan).forEach((line: string) => cmd.push("--plan", line));
|
||||
}
|
||||
if (args.tags) cmd.push("--tags", args.tags);
|
||||
if (args.due) cmd.push("--due", args.due);
|
||||
if (args.priority) cmd.push("--priority", String(args.priority));
|
||||
|
||||
if (cmd.length === 2) {
|
||||
return "Error setting fields: give at least one field to change";
|
||||
}
|
||||
|
||||
try {
|
||||
return await run(cmd, context);
|
||||
} catch (err: any) {
|
||||
return `Error setting fields: ${err.message}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const append = tool({
|
||||
description:
|
||||
"Add to a section of an existing worklane ticket without replacing what is there. The description gains a new paragraph; acceptance criteria and plan steps are added to the end of their lists, with steps numbered on from the last. Ticked criteria and handwritten content are left alone. To replace a section outright, use set.",
|
||||
args: {
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
description: tool.schema
|
||||
.string()
|
||||
.describe("Text to add as a new paragraph at the end of the description.")
|
||||
.optional(),
|
||||
acceptance: tool.schema
|
||||
.string()
|
||||
.describe("Acceptance criteria to add, one per line.")
|
||||
.optional(),
|
||||
plan: tool.schema
|
||||
.string()
|
||||
.describe("Implementation plan steps to add, one per line.")
|
||||
.optional(),
|
||||
},
|
||||
async execute(args: Record<string, any>, context: ToolContext) {
|
||||
if (!args.ticket) {
|
||||
return "Error appending: ticket is required";
|
||||
}
|
||||
|
||||
const cmd: string[] = ["append", args.ticket];
|
||||
if (args.description) {
|
||||
descriptionLines(args.description).forEach((line: string) =>
|
||||
cmd.push("--description", line),
|
||||
);
|
||||
}
|
||||
if (args.acceptance) {
|
||||
itemLines(args.acceptance).forEach((line: string) =>
|
||||
cmd.push("--acceptance", line),
|
||||
);
|
||||
}
|
||||
if (args.plan) {
|
||||
itemLines(args.plan).forEach((line: string) => cmd.push("--plan", line));
|
||||
}
|
||||
|
||||
if (cmd.length === 2) {
|
||||
return "Error appending: give at least one section to add to";
|
||||
}
|
||||
|
||||
try {
|
||||
return await run(cmd, context);
|
||||
} catch (err: any) {
|
||||
return `Error appending: ${err.message}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const chown = tool({
|
||||
description:
|
||||
"Change the owner of a worklane ticket. This is the only writer of the Owner field: set does not offer it. The user is free text and is checked against nothing. Note the argument order, user first and ticket second, after Unix chown.",
|
||||
args: {
|
||||
user: tool.schema
|
||||
.string()
|
||||
.describe("New owner (required). Free text, checked against nothing."),
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
},
|
||||
async execute(args: Record<string, any>, context: ToolContext) {
|
||||
if (!args.user) {
|
||||
return "Error changing owner: user is required";
|
||||
}
|
||||
if (!args.ticket) {
|
||||
return "Error changing owner: ticket is required";
|
||||
}
|
||||
|
||||
try {
|
||||
return await run(["chown", args.user, args.ticket], context);
|
||||
} catch (err: any) {
|
||||
return `Error changing owner: ${err.message}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* check and uncheck differ only in the verb, so the tool is built once.
|
||||
*
|
||||
* The criteria are required here even though the CLI makes them optional: without any
|
||||
* the CLI prompts, and there is no terminal on this side of the pipe. The CLI answers a
|
||||
* missing criterion with the numbered list on stderr, which run() relays, so the model
|
||||
* sees the options and can retry with a number.
|
||||
*
|
||||
* One value per line, like the other list arguments, and every value goes in one call.
|
||||
* The CLI resolves them all before it writes, so a bad term costs nothing, and finishing
|
||||
* a ticket is one tool call rather than one per box.
|
||||
*/
|
||||
function checkboxTool(verb: "check" | "uncheck") {
|
||||
const past = verb === "check" ? "Checked" : "Unchecked";
|
||||
|
||||
return tool({
|
||||
description:
|
||||
`${past === "Checked" ? "Tick" : "Untick"} acceptance criteria on a worklane ticket. ` +
|
||||
"Every criterion not named keeps its state. Identify each one by its number as shown by show, " +
|
||||
"or by a substring of its text; a substring matching more than one is an error listing them. " +
|
||||
`Pass several, one per line, to ${verb} them in a single call, or the single word all for every ` +
|
||||
"criterion on the ticket. If any value cannot be resolved the whole call is refused and nothing " +
|
||||
"is written, so a partly wrong list never leaves the ticket half-marked.",
|
||||
args: {
|
||||
ticket: tool.schema
|
||||
.string()
|
||||
.describe("Ticket UUID prefix (4+ chars) or title substring (required)"),
|
||||
criteria: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"Criterion numbers as shown by show, or substrings of their text, one per line. " +
|
||||
"Or the single word all for every criterion (required)",
|
||||
),
|
||||
},
|
||||
async execute(args: Record<string, any>, context: ToolContext) {
|
||||
if (!args.ticket) {
|
||||
return `Error running ${verb}: ticket is required`;
|
||||
}
|
||||
|
||||
const terms = args.criteria ? itemLines(String(args.criteria)) : [];
|
||||
if (terms.length === 0) {
|
||||
return `Error running ${verb}: criteria is required, give the numbers, substrings, or all`;
|
||||
}
|
||||
|
||||
try {
|
||||
return await run([verb, args.ticket, ...terms], context);
|
||||
} catch (err: any) {
|
||||
return `Error running ${verb}: ${err.message}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const check = checkboxTool("check");
|
||||
export const uncheck = checkboxTool("uncheck");
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
# AGENTS.md
|
||||
|
||||
## Project Structure
|
||||
- `src/main.rs` - All application logic
|
||||
- `src/main.rs` - dispatch, the SIGPIPE reset, and the TUI event loop
|
||||
- `src/command.rs` - CLI argument definitions using clap derive
|
||||
- `tests/` - Integration tests using `assert_cmd` and `assert_fs`
|
||||
- `src/completions.rs` - the generated completion script and the fish half that asks the board
|
||||
- `src/handlers.rs` - one `cmd_*` per subcommand
|
||||
- `src/util.rs` - the ticket format, resolution, rendering and the palette
|
||||
- `src/campaign.rs` - the campaign file format, its resolution, its index and its members
|
||||
- `src/tui.rs` - board state, the change digest, and the ratatui draw
|
||||
- `src/clipboard.rs` - the OSC 52 write and the base64 it carries, the board's only way out to the clipboard
|
||||
- `src/install.rs` - the embedded agent assets and the compare-and-refuse install
|
||||
- `assets/SKILL.md` - the agent skill for the CLI itself, embedded with `include_str!`
|
||||
- `assets/REVIEW.md` - the agent skill for reviewing a finished ticket, shipped the same way. Assets are named after the role they teach; `SKILL.md` keeps its name because the role it teaches is the CLI
|
||||
- `assets/PLAN.md` - the agent skill for grooming the whole board: priorities, due dates, tags and campaigns
|
||||
- `tests/` - Integration tests using `assert_cmd` and `assert_fs`, one file per command
|
||||
- Unit tests live beside the code in `#[cfg(test)] mod tests`, in `util.rs`, `handlers.rs` and `tui.rs`
|
||||
- Ticket files stored as `.md` in `.worklane/<status>/` directories
|
||||
- Campaign files stored as `.md` in `.worklane/campaigns/`, which is beside the status directories and deliberately not in `status_dirs()`
|
||||
|
||||
## Ticket File Format
|
||||
- Filenames: `<uuid_v4>_<slug>.md`
|
||||
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Status`
|
||||
- The slug is the title through `slug()`: lowercased, alphanumerics plus `-` and `_` kept, spaces turned into dashes. `Ticket 06` lands as `<uuid>_ticket-06.md`. Derive fixture filenames through `slug()`, never by hand
|
||||
- Metadata fields parsed by `parse_ticket_field()`: `ID`, `Priority`, `Tags`, `Due`, `Owner`, `Created At`, `Committed On`, `Submitted On`, `Completed On`, `Campaign`, `Status`. The last four are the ones no ticket is born with: `add` writes none of them, so they are inserted on demand, against `METADATA_ORDER`, which is also what keeps `Status` last
|
||||
- The 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`
|
||||
- Comments stored in `.worklane/comments/<ticket_uuid>/<timestamp>.md` with `**Comment**`, `**Author**`, `**Time**` fields
|
||||
@@ -16,11 +30,18 @@
|
||||
## Status Workflow
|
||||
`backlog` → `committed` → `reviewing` → `done`
|
||||
|
||||
**How to use worklane is in `assets/SKILL.md`, not here.** That document is what
|
||||
`worklane install-skill` ships, so it is the one place the flow, the move-as-you-work
|
||||
rule and the argument traps are written down. Read it before working a ticket in this
|
||||
repo. Do not restate any of it in this file: a second copy is a copy that goes stale,
|
||||
and this file is for what someone changing worklane's own code needs.
|
||||
|
||||
## Testing
|
||||
- Run: `cargo test`
|
||||
- Tests use `assert_cmd` and `assert_fs` for CLI testing
|
||||
- `setup_worklane()` creates temp `.worklane/` with all four status folders pre-created
|
||||
- `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)
|
||||
- **`cargo clippy --all-targets` is clean. Keep it clean**, and do not silence a lint that is pointing at something real. The only two `allow`s in the tree sit on the `create_ticket` fixtures in `cmd_mv.rs` and `cmd_show.rs`, each carrying the reason and what would replace it
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
@@ -30,13 +51,243 @@
|
||||
- Prefer explicit `match` over `unwrap_or_default()` for clarity
|
||||
- Use `unwrap_or_else(|| expr)` for lazy defaults, `unwrap_or(val)` for eager defaults
|
||||
- Use `anyhow!()` with context strings that include identifying info (e.g. UUID, title) not bare values
|
||||
- A command whose arguments run past a handful takes a clap `Args` struct, not an inline variant with a matching parameter list: `AddArgs`, `SetArgs`, `AppendArgs`, `CheckArgs`. `add` was nine positional parameters threaded from `main` before it became `AddArgs`, and the handler destructures the struct so the body reads the same as before
|
||||
|
||||
### CLI Arguments
|
||||
- The prose arguments carry `allow_hyphen_values`, via the `PROSE` constant in `command.rs`: `add --title`, `--description`, `--acceptance`, `--plan`, and the `comment` body. Ticket text quotes flag names constantly, and without it a criterion reading `--print is supported` is parsed as a flag and the whole ticket is refused with nothing written
|
||||
- **The trade:** on those five arguments a genuinely mistyped flag now lands as content rather than raising a usage error. That is the right way round for prose and the wrong way round for anything else, which is why `due`, `priority`, `tags`, `owner` and `status` are deliberately left without it. A mistyped flag there is still a usage error, exit 2, and no ticket is written. Do not add `PROSE` to a new argument unless it holds prose
|
||||
- **`--due` is validated at parse time by `iso_date`, the way `--priority` is by `priority_level`.** A date that is not real is a usage error, exit 2, with nothing written, which is the whole point of leaving the scalars without `PROSE`. One parser serves `add` and `set`: the field has one definition of what it accepts, and validating only `add` would leave `set` open, which is the command a grooming sweep actually uses
|
||||
- **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 `non_empty`'s message about clearing rather than the date message. Somebody typing it is reaching for a way to clear the field, and the useful answer is that clearing is not supported yet
|
||||
- **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`
|
||||
- A bare `--` is a value when it follows an option (`--title -- ` stores `--`) and clap's end-of-options marker when it sits in a positional. So a `comment` body of exactly `--` needs its own separator, `comment <ticket> -- --`. Without it the body is reported missing and nothing is written, which is a clear failure rather than a silent drop
|
||||
- `add` has no positionals, so anything after a bare `--` is an unexpected argument and fails
|
||||
- **A paragraph break in a description is an empty `--description` value.** `cmd_add` joins the values with a single newline, so `-d "First." -d "" -d "Second."` writes the blank line. `trim_blank_ends()` drops blank values at either end, so a break never lands against a section heading, and an all-blank description reads as no description. Interior runs are kept verbatim rather than collapsed
|
||||
- `--acceptance` and `--plan` are lists, one criterium or step per value, so a blank there is spacing rather than content and the opencode wrapper drops it. Only `--description` preserves blanks
|
||||
|
||||
### Completions
|
||||
|
||||
- **Two halves, and the split is the point.** `clap_complete` generates the structure from the clap definition, so a new flag or subcommand is completed without anyone touching `completions.rs`. Only fish gets the second half, appended by `fish_dynamic()`, and it holds exactly what clap cannot know: the tickets on the board
|
||||
- **The dynamic values come from worklane itself**, as `worklane ls --ids` in a command substitution, one run per keypress at 2.5ms in release. So the completions are only as current as the binary on PATH: an older one without `--ids` completes nothing, which is a reinstall rather than a bug
|
||||
- **What clap does and does not emit.** It emits the possible values of an *option*, which is why `mv --status <TAB>` needs nothing here, and nothing for a *positional*, which is why the `ls` status and the `completions` shell are listed in the fish half. Both lists are read off the enums with `possible_values`, never written out, so a fifth status appears in the script on its own
|
||||
- **Position is counted, not inferred.** `__worklane_first_arg_of` and `__worklane_second_arg_of` check `$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
|
||||
- **`TICKET_COMMANDS`, `TICKET_SECOND_COMMANDS` and `TICKET_FLAGS` are kept honest by tests**, which walk the clap definition and fail on a ticket-taking subcommand that is in neither list, or in the list for the wrong position. A nested subcommand is not walked: `campaign` is the only one, none of its three takes a ticket, and the token counting could not tell them apart if one did
|
||||
- **`ls --ids` is the machine-readable listing**, and the only output 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
|
||||
|
||||
### Filtering the Listing
|
||||
- **The filters are one call, `filtered`,** because `ls` collects a column in three places (a named status, the counts, and the grouped listing) and three call sites are three chances to apply a different set. Every filter is an `Option` and none asked for keeps everything, which is what makes them compose in any combination without a rule per pair
|
||||
- **`--tag` matches whole values, not the field.** `parse_tags` has already split the comma-separated field, so the filter compares against those trimmed values: `--tag bug` is not answered by a ticket tagged `bugfix`, and `--tag "cli, filter"` matches nothing, because the field as written is not itself a tag. A ticket with no tags matches none
|
||||
- **Case sensitive**, the opinion the field already takes: `tag_color` draws `Bug` and `bug` in two colours because they are two tags. A filter that folded them would list tickets carrying a tag nobody asked for, and would hide exactly the split a grooming sweep is looking for
|
||||
- **One tag per invocation.** Several would have to decide between and and or, and neither reading is obviously right for a board this size. That decision is its own ticket, along with a substring or regex match and a tag filter on the tui
|
||||
- **A tag nothing carries lists nothing rather than being refused**, which is the opposite of `--campaign`. A campaign is an object that either exists or does not, so it is resolved before anything is read and an unknown one is an error. A tag is free text with no registry: there is nothing to resolve against, and refusing an unknown one would mean maintaining a vocabulary the format deliberately does not have. `assets/PLAN.md` tells the agent to check the spelling when a listing comes back empty, since that is the failure this trades for
|
||||
- An emptied status keeps the message `ls` already gives, `No tickets in '<status>' status.`, rather than one per filter naming what excluded them. That is pre-existing behaviour for `--priority` and `--campaign`, and one message for every filter is the consistent half of it. If it should name the filter, that is a change to what the CLI prints for three flags at once and belongs in its own ticket
|
||||
- **`cmd_ls` takes an `LsArgs`**, which is what the boundary in the Rust Style rule came to: four filters, an output mode and the directory, two of them adjacent `Option<String>` values a caller could swap silently. `--ids` was the argument that tipped it, the way `add` became `AddArgs`. A new filter is a field there, not a parameter
|
||||
|
||||
### Editing a Ticket
|
||||
- `set` replaces a field, `append` adds to a section. The verb carries the meaning, so no flag needs a replace-or-append prefix, and `append` only offers the sections that hold multiple lines
|
||||
- **One field, one writer.** `set` has no `--owner` (that is `chown`'s) and no `--status` (that is `mv`'s), and neither `add`, `set`, `append` nor `chown` can reach the three status stamps, which `mv` writes as a side effect of the move. Do not add any of them
|
||||
- `chown` takes the **user first and the ticket second**, after Unix `chown`, and is the only command that does not start with the ticket. Deliberate: the name borrows the Unix association, so the order borrows it too. A swap is left to `resolve_ticket`, which refuses a bare username as a ticket. No argument is inspected to see whether it *also* names a ticket, since such a check would only fire where resolution already fails and would stay silent on the one case it cannot catch, a ticket whose title is the username
|
||||
- `cmd_chown` is `set_metadata_field` plus `save_ticket`, with the same whole-file no-op comparison `set` uses and the same `report()` output, so nothing about writing a field lives twice
|
||||
- Sections are a table in `util.rs`: `DESCRIPTION`, `ACCEPTANCE`, `PLAN`, each with a heading, a label, the placeholder `add` writes when empty, and a `SectionKind`. Adding a section later is one entry, not edits in both commands
|
||||
- Everything is targeted line surgery, never a regenerated file. That is what keeps a ticked criterion ticked and a handwritten `## Notes` section intact when an unrelated field changes. `section_body()` finds the lines to touch, `set_metadata_line()` does the metadata, and every other byte is copied through
|
||||
- Appending to a numbered section continues from the count of steps already there and does not renumber what is above it, so a handwritten line in the section survives exactly as written
|
||||
- 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` in `command.rs`. Clearing a field is not supported yet, and the error says so rather than guessing
|
||||
- No-op detection compares the whole file before and after each edit, so a field set to the value it already holds is reported unchanged and nothing is written
|
||||
- `find_ticket_file()` matches on the uuid, never the title. Duplicate titles are allowed, so a title scan can land on a different ticket than the one resolved: `mv <uuid-of-second>` used to move the first ticket sharing its title
|
||||
- `write_then_replace()` is the only way a ticket file is written. Content first, rename second, so a failure leaves a correct ticket under a stale name rather than a half-written one
|
||||
|
||||
### Checking Off a Criterion
|
||||
- `check` and `uncheck` are separate commands, not one verb with a flag. They share `CheckArgs` and `cmd_check(args, checked)`
|
||||
- `criteria()` is scoped to the Acceptance Criteria section and counts only checkbox lines, so a checkbox written into a description is not a criterion and a handwritten line inside the section takes no number
|
||||
- `set_criteria()` splices only the character between the brackets, and takes every line in one pass. Rebuilding the line would normalise its indentation and whatever spacing followed the checkbox
|
||||
- Each criterion term is the keyword `all` first, an index second, a substring third. So a criterion whose text is literally `2` is reachable only by substring, and one whose text merely contains "all" only by its number or a longer substring. `is_all_criteria()` and `is_index()` sit beside each other in `util.rs` for that reason
|
||||
- **The keyword wins over the text on purpose.** Ticking every box is the reason the word is typed, and a board where `all` sometimes means one criterion and sometimes means the lot would be worse than one that can be addressed another way. `all_is_the_keyword_and_not_a_substring_of_the_text` pins it against its own fixture, so the shared one keeps its three criteria and its numbering
|
||||
- **A number out of range is a bad index, not a failed substring search**, and says so. `is_index()` makes that distinction
|
||||
- Any listing of a subset must keep the real numbers, via `numbered_criteria()`. Renumbering the matches from one contradicts the advice to use the number and points at the wrong criterion
|
||||
- With the criterion omitted: prompt when stdin is a terminal, otherwise return the numbered list as an error. Never prompt unconditionally, the opencode wrapper has no tty and would block on a stdin that never closes. This is the same choice `resolve_ticket` makes for an ambiguous match, and for the same reason
|
||||
- **The criterion positional is variadic**, so `check <ticket> 1 3 "the footer"` is one call and one write. Variadic rather than a repeated flag: the terms address criteria that are already there, the way the ticket positional does, instead of carrying content the way `--acceptance` does. The prompt path is unchanged and fires on an empty list
|
||||
- **`resolve_criteria()` resolves every term before a byte is written, and one bad term refuses the whole batch.** A call that ticked the terms it understood and then failed would leave the ticket half-marked with nothing in the file to say which half was meant. It names the offending term alone rather than every failure at once, since each message carries the criteria listing and a batch of them would repeat the list per bad term
|
||||
- The chosen offsets are sorted and deduped, so the report reads in `show`'s order whatever order the terms arrived in, and a criterion named twice, or by both `all` and its own number, is marked and reported once
|
||||
- **Every named criterion gets a line, in `show`'s order, printed after the write.** A criterion already in the target state reads `Already checked 2: text` and does not count towards the write, so a batch where every box is already ticked writes nothing, which is the whole-file no-op rule the editing commands keep. The number is on the unchanged line too: without it a batch cannot be read back against `show`
|
||||
- `show` numbers the criteria as `1. [x] text`, so the index is visible where the ticket is read. The number replaces the list marker rather than joining it
|
||||
|
||||
### Relating Tickets
|
||||
|
||||
- **The Relations section is `relate`'s alone.** `RELATIONS` is in the section table but deliberately out of `section_args`, so `set` and `append` cannot reach it: a relation names a target that has to be resolved to a uuid first, and a prose flag would let an unresolvable line into the one section that is read back by machine. Same rule as Owner and Status, one field one writer
|
||||
- **`add` does not write the section.** The plan on 4179958 asked for it in the ticket writer; it is out on purpose. A `_No relations._` block in every new ticket is noise in every `show`, and the insertion path has to exist regardless for every ticket written before the section did, so leaving it out means one path that is always exercised rather than two
|
||||
- **The full uuid is stored, not the seven characters `ls` prints.** It resolves without a scan and cannot turn ambiguous as the board grows. `show` renders the short id and the target's title instead: the file is the machine's copy, the output is the reader's
|
||||
- **One direction is stored and the inverse is derived.** `blocked by` goes on the gated ticket rather than `blocks` on the blocker, because the gated ticket is the one whose move is refused and whose author knows about the dependency. `relates to` is symmetric and is written once, on whichever end the caller ran it from. `RelationIndex::inbound` finds the far end by scanning, which is what keeps `relate` a single-file write
|
||||
- **A line in the section that is not a relation is an error naming the ticket**, not a line quietly dropped. Nothing but `relate` writes there, so a bad line means a hand-edited file. The TUI is the deliberate exception: `detail_of` falls back to no block, since one corrupt ticket must not take the whole board down
|
||||
- **The block is built outside `content_trim` and passed in.** Half of it comes from other tickets and `content_trim` has only the body. It is spliced over the stored lines where the file has the section, and injected ahead of the metadata where it does not, because a ticket that is only pointed at has no section of its own and still has relations to show
|
||||
- `ensure_section` inserts against `SECTION_ORDER`, before the first following section that is actually in the file, and adds no blank line that was not already there. A handwritten `## Notes` between the plan and the metadata therefore keeps its place, and Metadata is in that list as an anchor rather than as something anything appends to
|
||||
- **The blocker check runs on every move**, after the already-in-that-status return and behind `force`. An open blocker is a reason not to start and a reason not to finish, and one rule is easier to hold than a table of which transitions care. A move to the status the ticket is already in is not a move, so it is not refused. `-f` now bypasses three rules, which is the right home for it: each one is a deliberate override of something the board would otherwise keep true
|
||||
- **A blocker that is not on the board warns and allows the move.** Refusing would wedge the ticket with no way out but `-f`, and a uuid nothing carries is a bookkeeping fault rather than a dependency. The refusal names **every** open blocker, since clearing the one that happened to be printed would leave the ticket blocked
|
||||
- Left out on purpose: removing a relation, which 4179958 assigns to 74904dc. The blocked marker on the card landed in b8ce18c, and it cost no scan of the board: the blockers ride along on the read that already builds the cards. See The Board View
|
||||
|
||||
### Campaigns
|
||||
|
||||
- **A campaign's state is derived, never stored.** Open until every member is done, computed by `Standing` from the members. A `Status` field on the campaign would be the same state in two places, and the two would disagree the moment a member moved. It is also why there is no `campaign mv` and no forward-only ruleset beside `mv`'s
|
||||
- **A campaign with no members is neither open nor done.** `Standing::state()` returns `None` there, and both callers print `no members`. Calling it done would make a container nothing has been filed against the most complete thing on the board; calling it open would claim work that does not exist
|
||||
- **Membership is one field on the member**, `Campaign` in the ticket Metadata, written only by `assign`. The member list is deliberately *not* on the campaign: that would put membership in two places, and would make one file that every assignment edits, which is contended the moment two agents share a board. So `add` has no `--campaign` and `set` has no `--campaign`, the same rule as Owner and Status
|
||||
- **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
|
||||
- **`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
|
||||
- `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
|
||||
|
||||
### The Board View
|
||||
- **The board is for a person, and only for a person.** Scripts and agents drive worklane through the CLI, which is what `assets/SKILL.md` teaches and what the integration tests pin. Nothing parses the drawn frame, so its layout is free to change: a new row on a card, a moved corner, a different colour or a hidden column breaks no caller. Judge a change here on whether it reads well, not on what it might break, and do not preserve a layout for compatibility's sake. What the CLI prints is the opposite case and is not covered by this
|
||||
- `worklane` with no subcommand and `worklane tui` both open it, the way a bare `frig` does. `Cli::command` is therefore an `Option`
|
||||
- The worklane directory is looked for **before** the terminal, so running outside one gives the usual "No .worklane directory found" rather than a complaint about the tty. Both errors stay reachable and both are testable without a pty
|
||||
- A missing tty is refused with a message naming a subcommand. Raw mode on a pipe fails with a bare "No such device or address (os error 6)", which explains nothing
|
||||
- **The watch looks at files, not directories.** A directory's mtime only moves on create and rename, so a ticket edited in place would be missed. `digest()` hashes every ticket and comment file's path, length and mtime. Comment files are in it because a comment added elsewhere has to reach the detail view
|
||||
- The digest guards the *rescan*, not the draw. ratatui diffs its buffer, so drawing every iteration is free; reading the tree every iteration is not
|
||||
- `notify` is deliberately not a dependency. Polling a tree of tens of small files on the 250ms tick is enough, and the reason is recorded on f6af387
|
||||
- Cards come from `collect_ticket_items`, the same source `ls` uses, so there is no second parser. `TicketItem::path` exists for the detail view
|
||||
- **The detail view scrolls on `pgup` and `pgdn`, not on up and down.** Up and down stay on the selection with the modal open, so a whole column can be read without closing it, and the modal follows. That is worth more than the two keys, which is why the scroll went elsewhere rather than taking them
|
||||
- The scroll offset is clamped against the *wrapped* line count, from `Paragraph::line_count`, which is why `ratatui` carries the `unstable-rendered-line-info` feature. The paragraph wraps on words, so a clamp on the raw lines would stop short of the end or scroll past it into blank space. Counting the wrapping by hand would only agree with the widget until one of the two changed
|
||||
- The clamp runs on the keypress and again in the draw. The terminal can be resized between the two, and a tick can shorten the ticket under a reader who is already at the end
|
||||
- The offset resets when the selection moves and when the modal is closed, so a ticket opens at its top. It deliberately does *not* reset on a tick: an edit elsewhere in the tree must not throw the reader back to the top of what they are reading
|
||||
- **The overlay carries a page indicator on the bottom right of its border**, `pg 2/8`, so a long ticket does not open looking exactly like a short one. `Block::title_bottom` with a right-aligned `Line`, which spends no text row, the trade the title already makes on the top border. The two cannot crowd each other: they are on opposite borders
|
||||
- **`wrapped_height` is the one measurement.** `last_offset` is it less the viewport and `page_indicator` takes the same two numbers, so the clamp and the indicator cannot disagree. A second `line_count` call, or a count of the raw lines, is a number free to drift, and an indicator that says there is more to read where the scroll refuses to move is worse than none
|
||||
- **The furthest offset is the last page by definition, not by division.** The clamp stops at the wrapped height less the viewport, which is not a page boundary, so the final screenful is partial: `offset / step + 1` reads `pg 2/3` at the bottom of a 25 row ticket in a 10 row viewport and claims there is more below
|
||||
- **The pages are counted in `scroll_step`, a screenful less the overlap line, not in whole screenfuls.** The step is what the keys take, so counting in it names only pages `pgdn` can land on. Counting by screenfuls puts a 30 row ticket in a 10 row viewport at `pg 3/3` two rows short of its end, since three presses are what it takes to get there
|
||||
- The indicator is dropped whole on an overlay too narrow for it, the rule a corner and the tags row already follow, and absent entirely when nothing scrolls, the way an untagged card spends no row on tags
|
||||
- `page_indicator` takes four numbers and returns an `Option<String>`, so every case above is pinned without a terminal. The drawn tests exist for the two things arithmetic cannot answer: which border it landed on and what colour it reached the screen in
|
||||
- **Columns scroll to keep the selected card in view.** `Board::offsets` holds one offset per column, parallel to `columns` and resized in step by `reload`, so a column you leave stays where it was. The keypress aligns the focused column via `follow_selection(screen)`, taking the screen size for the same reason `scroll_detail` does: the visible height belongs to the terminal, which only the caller measures between draws
|
||||
- Card heights are measured on `card_lines`, never assumed, on both the keypress and the draw side (`card_height`, and the `starts` vec as the cards are built). An alignment that trusted a fixed card height would drift from the renderer the first time the card changed shape
|
||||
- The draw aligns the focused column again on its own geometry, so a resize between keypress and frame cannot hide the selection, and caps every column against blank space past its last card. The stored value may go stale after a tick shrinks the column; that is fine, because what is drawn is corrected immediately and the next navigation writes the correction back
|
||||
- Entering another column follows the selection rather than resetting to its top. The card index carries across columns, so a reset would open the column with the highlight below the fold whenever it was — the opposite of the detail view's reset-on-selection-move, where each ticket genuinely starts at its own top. The index is shared and clamps permanently when a shorter column pulls it down, so a column you return to follows the selection to where it now sits rather than holding your old place
|
||||
- **The footer names only keys that work.** It read `↑↓ scroll` when nothing scrolled at all, which sends the reader looking for their own mistake. A UI that misdescribes itself is worse than one that is merely incomplete
|
||||
- **`q` and `esc` are one key: close what is open, quit when there is nothing left to close.** `q` used to set `should_quit` outright, so a reader who pressed it to put a ticket away lost the board instead, which is not what `q` does anywhere else that lays a document over a list. One match arm in `main.rs`, not two: two arms carrying one rule is how a later edit changes it for one key and not the other
|
||||
- **The rule is `Board::dismiss`, not the match arm.** The dispatch in `main.rs` is not reachable from a test, so anything decided there is undecidable by the suite. The arm is the line that names the keys and nothing else. `the_dispatch_gives_q_and_esc_one_arm_and_leaves_ctrl_c_quitting` scans `main.rs` for what the arm cannot say for itself, over whitespace-collapsed source so rustfmt cannot fail it
|
||||
- **The footer's last slot always answers how to get out**, and with a ticket open the honest answer is `ctrl-c`, the only key left that quits in one press. Going on saying `q quit` there would be 1b78a24 in the other direction: a footer describing a key by what it used to do
|
||||
- **The overlay names its ticket on the border, not at the head of the paragraph.** `Board::detail` is a `Detail` carrying the title, the id and the text, because the name has to travel beside the body rather than inside it: `content_trim` drops the `# ` heading on purpose, since `cmd_show` prints it, and anything in the paragraph scrolls away
|
||||
- `detail_title` cuts the string itself instead of leaving it to ratatui, which truncates an overlong block title at whatever cell it reaches and would take the id with it. Cut against the inner width, so the id survives whole and the name ends in an ellipsis. The id goes first because that is how every other view addresses a ticket
|
||||
- The detail view renders with colour off. ratatui draws styled spans, so an escape sequence in a paragraph would be printed as literal bytes. `content_trim` and `format_comments_with` take the colour decision for that reason
|
||||
- Read only. Moving a card by keypress is a follow-up, deliberately kept out until the watch and render loop were solid
|
||||
- **A card is four corners with the title between them:** mark and short id top left, due top right, owner bottom left, criteria count bottom right. The two numbers are in corners because that is where the eye goes for one, and both were invisible at the end of a line of prose
|
||||
- The title takes one row or two, wrapped on spaces, with an ellipsis when even two are not enough. One row when one is enough: a second, blank row on every short ticket spends the column's height on nothing
|
||||
- **A card's height therefore depends on the column's width**, so `card_lines` and `card_height` both take it. `column_areas` is shared between the draw and `follow_selection` for the same reason: `Ratio` hands the remainder column to whichever slot it likes, and reproducing that arithmetic by hand is how the measurement and the draw come to disagree about where a card starts
|
||||
- **A corner that will not fit is dropped whole**, never truncated or wrapped: half a date reads as a different date, and a card that reflows in a narrow column changes height, which the scroll would then have to chase. The left corner is the ticket's identity and always stays
|
||||
- The criteria count is a field on `TicketItem`, filled in `collect_ticket_items` where the file is already being read, and counted through `criteria()` so a checkbox in a description is not counted here or numbered by `show`. Do not count per card: that re-reads every ticket body on every draw instead of on the tick that changed something. `None` rather than `[0/0]` for a ticket with no criteria
|
||||
- **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
|
||||
- **The mark goes after the id, not before it.** Ahead of the id it would push every id in the column out of line whenever one card was blocked, which costs more than one card's state is worth. It is measured before the project label and the due date, so both give way to it: those are context for a ticket somebody can start, and this is the one thing on a card that says not to. Dropped whole when the row cannot hold the identity and the mark together, the rule a corner follows
|
||||
- **`blocked` is on `Card`, not on `TicketItem`.** The answer lives on two tickets at once, so no card can reach it alone, and it is settled at reload the way `project` is. What `collect_ticket_items` fills is the ticket's own `uuid` and its `blockers`, both read off the file it is already holding; `mark_blocked` then walks the four columns once for a uuid-to-status map and once to answer every card. No file is read twice and nothing is asked per draw
|
||||
- **A blocker the board does not hold marks nothing**, the answer `mv` already gives a dangling uuid. A Relations section that cannot be parsed reads as no blockers, the exception `detail_of` makes for the same reason: `show` and `mv` are where a hand-edited file is reported, and a board that will not draw because one ticket is malformed is the worse failure
|
||||
- **The merge carries the flag rather than recomputing it.** `relate` resolves its target inside one `.worklane`, so a blocker in another project is not a relation anything can record; resolving over the merged columns would let one project's uuid match another project's ticket. That is b8ce18c's fourth plan step and the answer is no
|
||||
- `project_label` takes the width the row has already spent, measured off the spans, rather than adding up the widths those spans are supposed to have. The hand-written version left out the space after the priority mark, so a cut label was handed one cell more than the column had; `the_project_label_leaves_the_row_inside_the_column` pins it
|
||||
- `due_date` cuts a due value back to its date only when it has one. The field is not validated (daa0e79), so it can hold a time or free text, and taking the first word regardless would turn "next friday" into "next"
|
||||
- **Done is hidden until `d` asks for it.** Not a new opinion: `ls` already counts done in its summary and leaves it out of the listing. Done only grows, so a quarter of the width was going to the column least often read. The footer carries its count while it is hidden, which is the board's version of that summary line
|
||||
- **Hiding is a change to what is drawn, never to what is read.** `reload` still scans the done directory and `digest` still watches it, so the footer count is right and revealing the column needs no rescan. Do not "optimise" that into a conditional scan
|
||||
- `visible()` returns a prefix of `columns`, not a filter, which is what keeps `column` and `offsets` valid as indices into either. It is derived from where `DONE` actually sits rather than assuming the last slot, and `the_done_column_is_last` pins the assumption. A status inserted after done would otherwise hide two columns in silence
|
||||
- Hiding the column under the selection moves the selection to the last drawn column and **closes an open detail view**. The alternative, refreshing the modal onto whichever ticket the selection landed on, swaps what someone is reading without saying so, which is how a person acts on the wrong ticket. Showing done again is a no-op for the selection, since a column is appended rather than inserted
|
||||
- The choice is not remembered between runs. worklane has no config file and one flag is not a reason to start one; if it should persist, that is its own ticket
|
||||
- **Assert a column heading against the top border row, not the whole screen.** The footer names done too, so `screen.contains("done (0)")` passes on the footer whether the column is drawn or not. Three tests went vacuous that way the moment done was hidden; `headings()` and `footer()` exist so the next one does not. `headings()` locates the row through `board_area()` rather than taking row zero, since the tab row sits above it when more than one board is monitored
|
||||
|
||||
### The Search Prompt
|
||||
- **`search: Option<Search>` is the whole mode**, the shape `detail` uses: "the prompt is open" and "what is in it" cannot disagree, and closing it leaves nothing to reset. `Search` also carries `missed`, set when enter found nothing and cleared by the next edit, since the message is about the query that missed
|
||||
- **The prompt swallows every key it is given.** `Board::search_key` runs ahead of the action arms in `main.rs` and reports what it took, rather than every arm below asking whether a search is open. Typing `d` into a query must not toggle done and `q` must not quit; with no prompt open it takes nothing, so the dispatch is unchanged for every other state. The rule is on `Board` for the reason `dismiss` is: the arm is not reachable from a test
|
||||
- **`ctrl-c` is the one key it declines**, because a terminal application always honours it and a prompt that ate it would leave no way off the board. Every *other* control combination is swallowed and does nothing: it must not type its letter, and it must not fall through either, since the action arms match on the code alone and `ctrl-d` would reach the one bound to `d`
|
||||
- **Esc is consumed by the search before it can mean anything else**, which is the collision e7612de left behind: `esc` and `q` close the overlay, and both have to lose to an open prompt. It falls out of the pre-branch rather than being ordered by hand
|
||||
- **`first_match` searches the *visible columns*, every card in them, not the rows on screen.** A query that answered differently on a tall terminal and a short one is not a search, and the jump scrolls the match into view anyway. Hidden columns stay out: with done hidden, a match there would put the highlight on a ticket that is not on the board. Reading order is column by column, then top to bottom
|
||||
- Id and title only, per 3b16540, both lowercased. The title has to be case insensitive to be worth typing, and giving the id the same treatment lets a pasted id match whatever case it was copied in. An empty or all-space query matches **nothing** rather than everything
|
||||
- **The jump goes through `select_at`, the tail `select_card` already used.** `follow_selection` scrolls the column the card is in, and the offsets are per column and on the `Tab`, so a jump across columns moves the right one; `refresh_detail` keeps an open overlay on the ticket the selection names. A second version of either is how a jump comes to scroll differently from the arrow keys
|
||||
- **A hit closes the prompt and a miss keeps it open**, marked, with the selection untouched. The query can then be corrected in place instead of retyped from `/`. Doing nothing visible is what makes a reader retype a query that was already right
|
||||
- **The prompt takes the whole footer row**, because the key list it replaces describes nothing that currently works while every key is going into the buffer. The typed query is drawn in the default foreground and the keys in grey: one is content, the other is chrome. `no match` is brightred beside the query it is about, since grey chrome is what a reader skips
|
||||
- **The real terminal cursor goes after the query**, not a glyph standing in for one. ratatui shows the cursor only for a frame that asked for it, so `set_cursor_position` is also what says "you are typing" while the query is still empty. Clamped to the row, so a query longer than the terminal leaves it on the last cell
|
||||
- Both closed footers name `/`, since the jump works with a ticket open as well: it moves the selection and the overlay follows
|
||||
- Out of scope on purpose, each its own ticket once the input mode exists: `n` and `N` for the next and previous match, searching the description, tags or owner, regex, and filtering the board down to matches rather than selecting one
|
||||
|
||||
### The Copy Key
|
||||
- **`y` copies the selected card's short id, over OSC 52 written by hand.** The board is where a ticket is found and the CLI is where it is acted on, and the only thing joining them was seven characters retyped off the screen. `y` reads as yank to the readers a keyboard board is for, and was the letter left: `q`, `esc`, `enter`, `space`, `hjkl`, the arrows, `pgup`, `pgdn`, `tab`, `backtab`, `d` and `/` were taken
|
||||
- **The mechanism was chosen against ssh**, which is where a board is often read. An escape sequence is the only one of the three ways that crosses the connection, since it is the terminal at the reader's end that owns the clipboard. A crate (`arboard` and its kind) wants X11 and Wayland libraries at build time, and on X11 the selection belongs to the process that set it: copy an id, quit, and the paste buffer is empty, which is precisely this flow. Shelling out to `wl-copy`, `xclip` or `pbcopy` is platform sniffing plus a process spawn, and does nothing on a machine where none of them is installed or on the far end of a connection. crossterm 0.28 is what ratatui 0.29 pins and it ships no clipboard command, and the backend types have to match whatever ratatui pins, so a newer crossterm cannot be picked up on its own
|
||||
- **The cost is paid knowingly: a terminal that ignores OSC 52 ignores it silently**, and tmux needs `set-clipboard on`. What `clipboard::copy` reports is whether the sequence was written, not whether it was honoured, and the footer message says no more than that. There is no reply to read: the query form of OSC 52 is refused by most emulators as a security matter, so nothing better is available to us
|
||||
- Base64 is twenty lines here rather than a dependency, because the only thing that goes through it is a seven-character id. Pinned on the RFC 4648 vectors, which cover both padding forms, since a wrong encoder would put plausible-looking rubbish on the clipboard
|
||||
- **`c` and not `p`**: the clipboard proper, not the X11 primary selection, since this is pasted into a command line. Terminated with BEL, which is what tmux documents and what every emulator that implements this at all accepts
|
||||
- **What is copied is `ticket.id`, the seven characters the card prints**, not the full uuid: they are what stops the retyping and what `show`, `mv` and `comment` all resolve. Decided by `Board::copy_text` rather than inside the arm that copies, so the string is a question the suite can ask without a clipboard. `None` on an empty column, since an empty string would take away whatever the reader had there and give nothing back
|
||||
- The project is left off even on the merge tab, where the id alone is not an address. This goes onto a clipboard to be pasted into a command line, and a second word in it would have to be deleted every time; running the command in the wrong project fails to resolve rather than acting on the wrong ticket
|
||||
- **The clipboard is handed to `Board::copy_selected_id` as an argument**, `clipboard::copy` from the dispatch and a closure from a test. That is what makes both answers drivable, and it keeps the terminal write out of the board state
|
||||
- **A failure is said in the footer, not returned.** There is nobody above it to handle one: the board goes on being drawn, and an error swallowed there would look exactly like a copy that worked until the paste came out wrong
|
||||
- **`Notice` is the board's one channel for saying something in words**, since a copy leaves nothing on screen to look at. `failed` means "nothing reached the clipboard" rather than "an error occurred", so an empty column and a refused write are one answer to the reader, both in brightred for the reason `no match` is
|
||||
- **It takes the whole footer row**, on a weaker reason than the prompt's: every key still works while a notice is up. It is that a message squeezed in beside the key list would move every key in it, and the row is the only part of the board that is not a ticket. Drawn after the prompt, which is an input and cannot be covered
|
||||
- **The notice is cleared by the next keypress, not by a timer.** No clock on the board and no wakeup in the loop, and the moment the reader does anything else the message has been read or was never going to be. Doing nothing leaves it up, which is the one state where it is still worth reading. `Board::clear_notice` runs ahead of `search_key` as well as the arms, since a key typed into a query is still a key, and it must never move into `tick`: the board redraws four times a second and a notice cleared there would never be read
|
||||
|
||||
### The Relations Block
|
||||
- **One builder, two painters.** `relation_rows` decides which edges there are, what they are called and which direction comes first; `relation_cells` decides the layout, the mark and the colours; `paint_cells` turns cells into escapes for the CLI and `span_of` turns the same cells into ratatui spans for the board. Two builders producing one block in two shapes is a pair free to disagree about ordering or padding, which is what this shape exists to prevent
|
||||
- **`Cell` is the unit both renderers take**: a run of text and the colour it is drawn in, `None` for the default foreground. The same trick as the palette itself, where `Color::ansi()` and `From<Color> for ratatui::style::Color` keep one colour from existing for one renderer and not the other
|
||||
- **`reference_cells` is the one spelling of a cross reference**, and `reference_cell` is it painted. The relations block and the Campaign field both go through it, so a dangling reference reads the same way wherever it is shown
|
||||
- **A row carries two marks, kind then status**: what sort of edge this is, then how far the ticket at the other end has got. `blocked by × ◐ (6ce2c47) Title`. Two questions are asked of this block and one glyph could not answer both: which rows hold this ticket up, and whether the ones that do are finished
|
||||
- The status went through one bad shape first. It was a rising bar, `▁▄▆█`, as the only mark, which read as an undifferentiated column of blocks and left the kind to five long words that blur when a ticket carries several. Then the kind took the column alone and the status was lost. Both, in that order, is the answer
|
||||
- **Both directions of a kind carry one mark.** `blocked by` and `blocks` are the same edge read from two ends, and the label is what says which end you are on. `both_directions_of_a_kind_carry_one_mark` pins it
|
||||
- **`×` is `BLOCKED_MARK`, the same constant a held-up card draws**, in the same brightred. On a card it says this ticket is held up and in the block it says this edge is what holds one, which is one word, so one glyph and one definition. It lives in `util.rs` for that reason, not in `tui.rs` where the card is
|
||||
- **The kind marks stay out of the priority vocabulary**, which owns `●◐○·`, and `no_relation_mark_is_a_priority_glyph` pins that against every level. They are the arrows the footer already draws, so they render wherever it does
|
||||
- **The status marks are those very circles, and what keeps them from reading as a level is width**: the meter is always two cells and a status mark is one. `the_status_mark_is_one_cell_where_the_meter_is_two` pins both halves. A card carries the meter and never a status mark, and the block carries the status mark and never a meter, so the two never sit in one column
|
||||
- **Both marks go ahead of the id**, where they describe the target rather than the row. Every row carries both, so nothing is pushed out of line the way the card's blocked mark would have been, which is why that one sits after the id and these before it
|
||||
- **The kind mark survives a target the board cannot find and the status mark cannot**, since a kind is read from the ticket's own file and a status from the board. `?` holds the column so the id does not move, and `_missing_` in grey is what says the target is gone
|
||||
- **Committed and reviewing are told apart by colour alone**, both being `◐`, so a pipe cannot tell them apart: `should_use_colors` is false and both read as under way. Accepted, because `●` and `○` are the two answers usually wanted and `show` on the target settles the rest, and `assets/SKILL.md` says so outright rather than leaving an agent to infer it. Do not fix this by giving one of them a colour that means something else
|
||||
- `RelationTarget` carries the title and the status in one `Option`, because they come from the same lookup and are absent together. It was taken out when the mark keyed on the kind alone and put back one commit later, which is the cost of a field nothing reads: correct at the time, and churn either way
|
||||
- **`show` and the board carry the same mark**, decided rather than left to be discovered: the rows are one builder, so giving the CLI the mark cost nothing, and two views disagreeing about what a relation shows would be the kind of difference nobody can explain later. That makes it a change to what the CLI prints, so it is a minor
|
||||
- **`Resolved.relations` is rows, not a rendered block.** That is what lets the board style them: an escape sequence in a ratatui paragraph is drawn as literal bytes (6d327df), so the block cannot arrive pre-painted. `content_parts` hands the text through already painted and the rows through untouched, which is the asymmetry the two renderers need
|
||||
- **`BodyPart` splits the body rather than building it twice.** Everything outside the relations block is rendered once, by `content_parts`; `content_trim` is that with the rows painted, and the board is that with the rows styled. `Body` is the accumulator, so a caller pushes text and rows without tracking which it pushed last
|
||||
- **`Detail.body` is a `Text`, and it is the only thing measured.** `last_offset` and the `Paragraph` both take it, so the clamp cannot wrap the body differently from the draw. `Detail::plain()` flattens it for the suite and is `#[cfg(test)]`: a second representation carried alongside the spans is a second thing to disagree
|
||||
- `detail_body` closes a line only where the text says, so a part that does not end on a newline runs on into the next one. The seam between text and rows is wherever the body put it rather than wherever a part happened to end
|
||||
- **The relations block is the only coloured part of the overlay body, and that is a decision, not an oversight.** The headings, the plan numbers, the criteria marks, the bold runs and the grey unset values are all painted by `show` and all flat on the board. The block earned its colour because it is where a reader compares several references at once, and because it was already data rather than prose: it arrives as rows for the status mark, so styling it cost nothing extra. Colouring the rest means giving every painted run in `content_parts` the `Cell` treatment, which is a much larger change with no reader's question behind it, and it is its own ticket. Do not paint one more section here without taking that on: two coloured sections and five plain ones reads as a bug, where one clearly does not
|
||||
|
||||
### Monitoring Several Boards
|
||||
- `worklane tui <path>...` takes any number of paths, each resolved through `find_worklane_dir` the way the working directory is: the first `.worklane` at or above it. No path is the working directory, so a bare `worklane` and `worklane tui` are unchanged
|
||||
- The failure **names the path** that had no board, since with several arguments "No .worklane directory found" does not say which one was wrong. Only when a path was given: a bare `worklane` has no path to name and keeps the message every other command gives, which is what its integration test asserts
|
||||
- Two paths inside one project resolve to the same `.worklane` and are monitored once. `projects()` dedupes on the resolved directory, not on the argument
|
||||
- **`Tab` owns the selection**, `column`, `card` and `offsets`, not `Board`. Sharing them across projects would point the selection at whatever unrelated ticket sat at the same place in the tab you switched to. `Board::current()` is the tab in view, and `show_done` stays on the board because it is a preference about the flow rather than about a project
|
||||
- The tabs are fixed for the run: a project cannot be added or dropped without restarting, so `Board::new` builds the tab list once and `reload` only refills each tab's columns. `reload` clamps **every** tab, and `select_tab` clamps again on arrival, because done may have been hidden while another tab was in view
|
||||
- The merge tab goes **first** and is where the view opens: it is the reason to monitor several boards at once. It is materialised in `reload`, from the cards already read, rather than computed per draw — the same reason the criteria count is filled in `collect_ticket_items`
|
||||
- The merge is **sorted**, through `by_priority_then_title` in `util.rs`, not concatenated. An overview whose order depended on the order of the arguments would bury one project's p1 under another's p5. That comparator is exported for this and is the one `collect_ticket_items` uses, so the two orders cannot drift
|
||||
- `Card` wraps a `TicketItem` with the project it came from, `Some` only on the merge tab. Decided at reload rather than passed down to `card_lines` as a "which tab is this" flag. `TicketItem` is therefore `Clone`: the merge holds a second copy rather than re-reading every tree
|
||||
- **The project follows the id, on the card and on the overlay border.** Across boards the id is not an address: two projects can hold the same title, and seven characters do not say where they live. `project_label` takes what the row has left after the mark and the id and ends in an ellipsis, and it is measured before the due date, so on the merge the project wins the narrow column and the date is what `corner_line` drops
|
||||
- `tab` and `shift+tab` cycle rather than clamp, unlike the cards and columns: a row of tabs is a ring, and there is no end of a list to run off. Both were free of every other binding — the columns took `hjkl` and the arrows
|
||||
- **The tab row is drawn only when there is more than one board**, so a single board is the view it has always been. `frame_rows()` gives it `Length(0)` otherwise, which keeps the row indices the same for both cases and is shared with `card_width` and `column_text_height` for the reason `column_areas` is: geometry reproduced by hand drifts from the draw
|
||||
- `digest_of` hashes each board's `digest` into one value, so a change in any of them redraws. Do not watch only the first
|
||||
|
||||
### Shipping the Agent Assets
|
||||
- The skill is embedded with `include_str!` from `assets/SKILL.md`, not copied by an install script. `cargo install` places binaries and nothing else, so an installed document that is not in the binary is a document that drifts from it
|
||||
- **One install path serves both agents:** `~/.claude/skills/worklane/SKILL.md`. Claude Code reads it, and opencode loads that directory as an external skill source alongside its own `~/.config/opencode/skill/`. Verified against opencode 1.15.10, whose built-in `customize-opencode` skill documents the table and whose `opencode debug skill` lists what it found there. Do not add the second path: it is two copies of one document, free to drift, for no gain
|
||||
- `Asset` carries the content, the path under its root and the word used in messages, so `install-tool` adds an entry and its own root rather than a second copy of the compare-and-refuse logic. That is why the module is `install.rs` and not `skill.rs`
|
||||
- `install()` takes the root as an argument. That is what lets the tests install into a temp directory instead of the home of whoever runs the suite, and the integration test redirects `HOME` for the same reason
|
||||
- **A modified copy is refused, not overwritten.** Someone may have edited it on purpose, and the message names `--print` so it can be diffed and `--force` so it can be replaced. A read error is not treated as absent either: the write reports the real reason
|
||||
- Three tests guard the document rather than the mechanism, and they are the ones that earn their keep: the frontmatter has to parse (both agents silently ignore a document without it), every `worklane <x>` the skill shows has to be a real subcommand, and every subcommand outside `NOT_FOR_AGENTS` has to appear in the skill. The last one catches a new command that nothing tells an agent about
|
||||
- `install-skill` looks for no board. The skill is what teaches an agent worklane, so needing a `.worklane` to install it would put it out of reach exactly when it is wanted
|
||||
- The assets under `.opencode/` are the user's, not this repo's to ship. Do not embed or install them. `reviewing-agent.md` there is the prior art the review skill grew out of and is deliberately **left in place**: its content is now in `assets/REVIEW.md`, but deleting a file under `.opencode/` is not this repo's call. Whether the stale copies there go is b2c5531's question
|
||||
- **`install-skill` writes every shipped document, and the name narrows it.** One document teaches the CLI and the others teach a job done with it, so a person who learned the invocation before a document existed still receives it. Requiring a name per document would mean a new skill silently never arrives for anyone who does not read the changelog
|
||||
- **`--print` requires the name.** It exists so a modified copy can be diffed, and a diff is against one document; printing them concatenated would be neither of them. The unnamed case errors with the list of names rather than guessing, the same choice the `comment --` body makes
|
||||
- The refusal message names the document it is about, `install-skill worklane --print`, since with several installed "compare with --print" does not say compare what
|
||||
- **A refused document does not stop the ones behind it.** The loop reports an outcome per document and the "pick it up on their next session" line is printed once, and only when something was actually written
|
||||
- **A role skill is its own document, not a section of `SKILL.md`.** The frontmatter description is the whole of what decides whether a skill loads, and one description cannot name both "anything touching a ticket" and "only when a review is asked for" without fitting neither. It is also why the review document does not restate the CLI: it says to read the `worklane` skill too
|
||||
- The review skill's own rules are guarded by `the_review_skill_keeps_the_decisions_that_define_it`, because each of them is a line an edit could drop without breaking anything: **the reviewer never ticks a criterion** (a tick is the implementer's claim, unticking is the review disagreeing, and one mark for both loses the disagreement), **never moves the ticket** (`mv` belongs to whoever does the work, the reviewer's half is the recommendation), and **never reviews the working tree when no commit names the ticket** (it says what it searched for and stops, since an untraceable ticket in `reviewing` is itself the finding)
|
||||
- **The plan skill is the one that can do damage, so its rules are the ones under test.** `set --tags` replaces the whole field, so a sweep that restates a ticket's tags incompletely deletes the rest, and a due date is neither validated nor clearable. `the_plan_skill_keeps_the_rules_that_bound_a_sweep` pins propose-then-apply and those two traps, because a document that loses them still reads like a plan
|
||||
- `.opencode/agent/feature-planner-agent.md` is **deliberately not folded into `PLAN.md`**. It decomposes a feature request into new tickets, which is intake; `PLAN.md` orders the tickets that already exist. Merging them would give one document two jobs and a frontmatter description that fits neither, which is the same reason the review skill is its own document
|
||||
- `every_agent_facing_subcommand_is_documented` stays on `SKILL` alone. It owns the CLI surface; a role document uses the handful of commands its job needs, and requiring the rest would fill a review document with `init` and campaigns to satisfy a test. The two checks that do run over every document are the frontmatter and that no document shows a command that does not exist
|
||||
|
||||
### Color and Output
|
||||
- Use `color_text()` helper for colored output — it respects `should_use_colors()` (terminal detection)
|
||||
- Color codes are defined in `get_color()`: red (31), cyan (36), orange (33), green (32), grey (38;5;8), magenta (1;35), brightred (38;5;9)
|
||||
- Use `color_text()` for coloured output — it respects `should_use_colors()` (terminal detection), and `paint()` is the same with the decision passed in
|
||||
- **`color_text()` is for the CLI's own printing only. Anything reachable from `content_trim` takes the decision as an argument and calls `paint()`**, because the board renders with colour off and an escape sequence in a ratatui paragraph is drawn as literal bytes. `nothing_the_body_renders_asks_the_terminal_for_the_colour_decision` scans this file and fails on a new caller; the allowlist is `ambiguous`, which builds a failed-search message for stderr
|
||||
- A function that takes an `enabled` flag must use it all the way down. `colorize_bold` honoured its flag on the early return and then asked `should_use_colors()` for the bold run, which made the flag a lie in half the function
|
||||
- **A test that asserts an absence has to be paired with one that asserts the presence.** The guard for this, an assert that the detail view holds no escape byte, could not fail: a test binary has no tty, so `should_use_colors()` was false and the leaking branch was never taken. The pair is now `content_trim(.., false)` has no escape and `content_trim(.., true)` still colours, which pins the flag as the only thing that decides
|
||||
- **The palette is the `Color` enum, not a string.** `Color::ansi()` gives the CLI its SGR sequence and `From<Color> for ratatui::style::Color` gives the TUI its equivalent, so a colour that exists for one renderer and not the other is a compile error. The stringly-typed version needed a test for exactly that, and a missing entry silently produced an empty prefix, which is how `magenta` came to be undefined
|
||||
- Reset color with `\x1b[0m` after colored text
|
||||
- Bold uses `\x1b[1;35m` (magenta bold)
|
||||
- Always test color output works correctly in both terminal and pipe modes
|
||||
- `quiet_broken_pipe()` runs first in `main`, restoring the default `SIGPIPE` disposition. A truncated pipe therefore kills the process with signal 13, which a shell reports as 141, instead of making `println!` panic. Do not wrap prints to handle write errors and do not reinstate `SIG_IGN`; the exit codes are documented in the README
|
||||
|
||||
### Color Guideline
|
||||
- UUID → red (31)
|
||||
@@ -45,20 +296,31 @@
|
||||
- Title → green (32)
|
||||
- Unknown values (`_None_`, `_Not set_`) → grey (38;5;8)
|
||||
- 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
|
||||
- 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
|
||||
- **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
|
||||
- **The index is multiply-shift, not `% TAG_COLORS.len()`.** The length is a power of two, so a modulus keeps only the low three bits of the hash, and FNV-1a's low bits carry only the low bits of the input bytes: multiplication cannot move information downwards. Under a modulus every pair of tags differing above bit 2, `bug` and `BUG` among them, landed in one slot regardless of the rest of the string. It looked like a *good* palette on this board, two colliding cards out of sixty-four, because the vocabulary had been folded into a handful of slots. Taking the top bits of a 128-bit product uses the whole hash
|
||||
- Eight tag colours means roughly one card in five shows two tags alike. That is arithmetic and is accepted: the colour groups a tag across cards, it does not tell two tags apart within one, and the tag text is beside it either way. Do not widen the list to chase the number on one board
|
||||
- Grey is indexed colour 8 in the 256-colour form, not SGR 90 or 37. Both of those failed on a real palette: 90 leans on the bright-black slot and 37 can sit on top of the default foreground. `\x1b[38;5;8m` is byte for byte what crossterm emits for ratatui's `Color::DarkGray`, the grey frig and pantop use for dimmed rows
|
||||
|
||||
### Code Organization
|
||||
- Colorization functions (`colorize_line`, `colorize_ordered`, `content_trim_colored`) handle markdown formatting
|
||||
- Colorization functions (`colorize_ordered`, `colorize_bold`, `content_trim_colored`) handle markdown formatting. `colorize_line` is gone: it was a `pub` alias for `colorize_bold` with one caller, and the only thing it added was asking the terminal
|
||||
- `show` renders the Metadata section as a two column table via `render_metadata_table`, not line by line. Column width is measured on the raw field names in characters and padding is applied before anything is styled: measuring a coloured string counts its escapes towards its width. `paint()` is `color_text()` with the colour decision passed in, which is what lets a test render both ways in one process
|
||||
- The title is printed once, by `cmd_show`. `content_trim_colored` skips the `# ` heading in the file content
|
||||
- Rules under headings are measured on the displayed name in characters, never on the raw line or in bytes
|
||||
- `resolve_ticket()` scans all status directories — it's the single source for ticket lookup by UUID prefix, title, or filename
|
||||
- `parse_ticket_field()` handles extracting metadata values from markdown format
|
||||
- `move_ticket_file()` stages the updated content in a temp file under `.worklane/`, renames it over the source, and only then renames the file into the target directory. Do not reorder these: renaming first and writing second leaves a ticket in its new directory claiming the old status, and writing to the target then deleting the source puts it in two directories at once. The temp lives outside the status directories so a leftover is never read as a ticket. A failure at the last step leaves the ticket in its old directory with a Status one move ahead, which the next `mv` corrects
|
||||
- Field lookup, read and write, is scoped to the lines under the `## Metadata` heading and anchored to the start of the line. Prose above it is free text: tickets in this repo quote field markers in their descriptions, and an unscoped search reads or rewrites those instead. `set_status_field()` carries the same scoping
|
||||
|
||||
### Ticket Resolution
|
||||
- `resolve_ticket()` returns `(status, title, content)` tuple
|
||||
- Priority: exact UUID prefix (8+ chars) > title substring > filename substring
|
||||
- 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
|
||||
- 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)
|
||||
- Never return empty strings for required fields — use `_Not set_` or `_None_` as defaults
|
||||
|
||||
@@ -71,6 +333,8 @@
|
||||
- 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
|
||||
- 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
|
||||
|
||||
Generated
+495
-17
@@ -11,6 +11,12 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
@@ -56,7 +62,7 @@ version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -67,7 +73,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -135,6 +141,21 @@ version = "3.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||
|
||||
[[package]]
|
||||
name = "cassowary"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
|
||||
|
||||
[[package]]
|
||||
name = "castaway"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.62"
|
||||
@@ -187,6 +208,15 @@ dependencies = [
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3be2ad0423bdbbb0e25bc89add796f3559706d4a95e1bc98e4d9662a957b6a19"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.6.1"
|
||||
@@ -196,7 +226,7 @@ dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -211,6 +241,20 @@ version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"cfg-if",
|
||||
"itoa",
|
||||
"rustversion",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
@@ -242,6 +286,65 @@ version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.28.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crossterm_winapi",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"rustix 0.38.44",
|
||||
"signal-hook",
|
||||
"signal-hook-mio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm_winapi"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
|
||||
dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "difflib"
|
||||
version = "0.4.0"
|
||||
@@ -254,6 +357,12 @@ version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "780955b8b195a21ab8e4ac6b60dd1dbdcec1dc6c51c0617964b08c81785e12c9"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
@@ -267,7 +376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -355,6 +464,8 @@ version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
@@ -400,6 +511,12 @@ version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.4.25"
|
||||
@@ -428,12 +545,43 @@ dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instability"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bf84e73fa6f27f299dec58e13223cf70db80da872eb921d4f6138342a0eabc8"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"indoc",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
@@ -464,24 +612,60 @@ version = "0.2.186"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -503,6 +687,35 @@ version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.17"
|
||||
@@ -543,7 +756,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -570,6 +783,36 @@ version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm",
|
||||
"indoc",
|
||||
"instability",
|
||||
"itertools",
|
||||
"lru",
|
||||
"paste",
|
||||
"strum",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.14"
|
||||
@@ -587,6 +830,19 @@ version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.4"
|
||||
@@ -596,8 +852,8 @@ dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -606,6 +862,12 @@ version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
@@ -615,6 +877,12 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
@@ -647,7 +915,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -669,18 +937,83 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"signal-hook-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-mio"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"mio",
|
||||
"signal-hook",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
|
||||
dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.26.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
|
||||
dependencies = [
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.26.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.117"
|
||||
@@ -692,6 +1025,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.27.0"
|
||||
@@ -701,8 +1045,8 @@ dependencies = [
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
"rustix 1.1.4",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -717,6 +1061,35 @@ version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-truncate"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"unicode-segmentation",
|
||||
"unicode-width 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
@@ -759,6 +1132,12 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.3+wasi-0.2.9"
|
||||
@@ -809,7 +1188,7 @@ dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@@ -856,15 +1235,37 @@ dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
@@ -886,7 +1287,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -897,7 +1298,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -924,6 +1325,15 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
@@ -933,6 +1343,70 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.51.0"
|
||||
@@ -969,7 +1443,7 @@ dependencies = [
|
||||
"heck",
|
||||
"indexmap",
|
||||
"prettyplease",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wasm-metadata",
|
||||
"wit-bindgen-core",
|
||||
"wit-component",
|
||||
@@ -985,7 +1459,7 @@ dependencies = [
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wit-bindgen-core",
|
||||
"wit-bindgen-rust",
|
||||
]
|
||||
@@ -1029,13 +1503,17 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "worklane"
|
||||
version = "0.3.0"
|
||||
version = "0.17.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
"assert_fs",
|
||||
"chrono",
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"crossterm",
|
||||
"libc",
|
||||
"ratatui",
|
||||
"tempfile",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
+8
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "worklane"
|
||||
version = "0.3.0"
|
||||
version = "0.17.2"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
@@ -8,6 +8,13 @@ clap = { version = "4", features = ["derive"] }
|
||||
anyhow = "1"
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
libc = "0.2"
|
||||
# unstable-rendered-line-info for Paragraph::line_count, which is how the detail view
|
||||
# knows where its text ends. Counting the wrapping by hand would only agree with the
|
||||
# widget until one of us changed.
|
||||
ratatui = { version = "0.29", features = ["unstable-rendered-line-info"] }
|
||||
crossterm = "0.28"
|
||||
clap_complete = "4.6.9"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "2"
|
||||
|
||||
@@ -5,9 +5,63 @@ 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 init` | Creates `.worklane/` with backlog, committed, reviewing, done directories |
|
||||
| `worklane add` | Creates a ticket in backlog with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--owner`, `--priority` flags |
|
||||
| `worklane ls [status]` | Lists tickets, sorted by priority then title. Optional positional status, and `--priority <1-5>` |
|
||||
| `worklane show <id>` | Shows ticket by UUID prefix (8+ chars) or title substring |
|
||||
| `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 mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
|
||||
| `worklane set <ticket>` | Replaces fields with `--title`, `--description`, `--acceptance`, `--plan`, `--tags`, `--due`, `--priority`. At least one required. Changing the title renames the file, keeping the UUID |
|
||||
| `worklane append <ticket>` | Adds to a section with `--description`, `--acceptance`, `--plan`. At least one required. The description gains a paragraph; list items go on the end, steps numbered on from the last |
|
||||
| `worklane relate <ticket>` | Records an edge to another ticket with `--blocked-by`, `--regression-of` or `--relates-to`, each repeatable. At least one required. Only the ticket named is written; `show` derives the other end by scanning. `mv` refuses to move a ticket blocked by one that is not done, unless `-f` |
|
||||
| `worklane chown <user> <ticket>` | Sets the Owner field, the only command that writes it. Free text, checked against nothing. User first and ticket second, after Unix `chown` |
|
||||
| `worklane check <ticket> [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 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 |
|
||||
|
||||
## Completions
|
||||
|
||||
```sh
|
||||
worklane completions fish > ~/.config/fish/completions/worklane.fish
|
||||
```
|
||||
|
||||
Also `bash`, `zsh`, `elvish` and `powershell`, though only fish gets the dynamic half.
|
||||
|
||||
The structure comes from clap, so new flags appear without anyone remembering to add them. The four
|
||||
statuses come with it, because a status is a value enum rather than a string. On top of that, fish
|
||||
asks worklane for the one thing only the board knows:
|
||||
|
||||
```
|
||||
worklane show <TAB> every ticket, id and title, done included
|
||||
worklane mv <TAB> the same, then --status <TAB> for the four
|
||||
worklane chown alice <TAB> the ticket, which is the second argument here
|
||||
worklane relate x --blocked-by <TAB>
|
||||
```
|
||||
|
||||
The tickets come from `worklane ls --ids`, one run per keypress, 2.5ms in release on a board of
|
||||
seventy-five tickets. Since fish runs whatever `worklane` is on PATH, **completions need the
|
||||
installed binary to be current**: an older one without `--ids` completes nothing. Re-run
|
||||
`cargo install --path .` after pulling.
|
||||
|
||||
`tui` is the one command whose argument is a path, so it is the one place fish still offers
|
||||
directories.
|
||||
|
||||
## Exit codes
|
||||
| Code | Meaning |
|
||||
|------|---------|
|
||||
| 0 | Success |
|
||||
| 1 | An error, such as no matching ticket or an ambiguous search |
|
||||
| 2 | A usage mistake, such as an unknown flag, an unreal `--due` date, a priority out of range or a status that is not one of the four |
|
||||
| 141 | Output was piped to a reader that stopped early, for example `worklane ls \| head -3` |
|
||||
|
||||
141 is 128 + 13, the shell's way of reporting death by `SIGPIPE`. Worklane restores
|
||||
the default signal disposition so a truncated pipe is quiet, the way `head` and
|
||||
`sort` are, rather than printing a panic. A script using `set -o pipefail` will see
|
||||
141 for a case that is not a failure, so guard for it there.
|
||||
|
||||
Whether a truncated pipe reports 141 or 0 depends on the size of the output, not on
|
||||
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.
|
||||
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
---
|
||||
name: worklane-plan
|
||||
description: Groom a worklane board as a whole rather than one ticket at a time: review whether the priorities are right relative to each other, plan work by setting due dates, check the tags for consistency, and find the tickets that belong together in a campaign. Use for questions about the backlog as a body of work, what to do next week, what is mis-prioritised or mis-tagged, and what could become one goal. Not for filing or working a single ticket.
|
||||
---
|
||||
|
||||
# Planning a worklane board
|
||||
|
||||
For "are the backlog priorities right", "plan in tickets for next week", "check the
|
||||
tagging", "which of these could be one campaign". The subject is the board, not a
|
||||
ticket. Filing one, working one and reviewing one are other jobs.
|
||||
|
||||
The CLI itself is the `worklane` skill: the statuses, how a ticket is addressed and
|
||||
which command owns which field. Read it too. This document is the judgement.
|
||||
|
||||
## The one rule
|
||||
|
||||
**Propose the whole set of edits, wait, then apply exactly what was approved.**
|
||||
|
||||
Every job here writes to many tickets at once, and no field can be cleared back to unset
|
||||
yet, so a date written onto the wrong ticket can only be overwritten, never taken off. A wrong
|
||||
edit to one ticket is a mistake; a wrong sweep is thirty of them with no undo. So a
|
||||
proposal is a list, one line per intended edit, each naming the ticket and the command
|
||||
that would make it:
|
||||
|
||||
```
|
||||
(1b78a24) priority 3 -> 1 worklane set 1b78a24 --priority 1
|
||||
(4179958) due -> 2026-08-29 worklane set 4179958 --due 2026-08-29
|
||||
```
|
||||
|
||||
Then apply what was approved and nothing else. Not "and a few obvious ones while I was
|
||||
there": an approval is for the list that was shown.
|
||||
|
||||
## Who writes what
|
||||
|
||||
Every field has exactly one command that writes it, and a sweep that reaches for any
|
||||
other way is editing the file by hand:
|
||||
|
||||
| Field | Writer |
|
||||
|-------|--------|
|
||||
| Priority, Due, Tags | `worklane set <ticket> --priority` / `--due` / `--tags` |
|
||||
| Relations | `worklane relate <ticket> --blocked-by` / `--regression-of` / `--relates-to` |
|
||||
| Campaign membership | `worklane assign <campaign> <ticket>` |
|
||||
| Owner | `worklane chown <user> <ticket>` |
|
||||
| Status | `worklane mv <ticket> --status <target>` |
|
||||
|
||||
**Never edit a ticket file directly.** The filename, the `Status` field and the directory
|
||||
have to agree, and the commands are what keep them agreeing. A hand-written Relations
|
||||
line is worse still: it is the one section read back by machine, and a target that does
|
||||
not resolve to a uuid is an error on every later read of that ticket.
|
||||
|
||||
The last two rows are in the table to be recognised, not used. See the closing section.
|
||||
|
||||
## Read the board first
|
||||
|
||||
```
|
||||
worklane ls # every status, counts then tickets
|
||||
worklane ls backlog # one status
|
||||
worklane ls --priority 1 # the top of the pile
|
||||
worklane ls --tag bug # one tag's worth of the board
|
||||
worklane show 1b78a24 # one ticket, with its relations and comments
|
||||
worklane campaign ls # the goals that already exist
|
||||
```
|
||||
|
||||
`ls` prints the mark, the id, the title, the owner and the due date. It does **not**
|
||||
print tags, so the vocabulary itself still has to be read off the tickets: `--tag` answers
|
||||
"what is tagged `bug`" and cannot answer "what tags exist", which is the question a
|
||||
grooming sweep starts from. Count the vocabulary with a `show` per ticket, then use
|
||||
`--tag` to check each candidate, and remember that `--tag` matches whole values case
|
||||
sensitively: `bug` and `Bug` are two answers, which is exactly the split worth reporting.
|
||||
|
||||
Read `done` too when the question is about what to do next. What was finished last is the
|
||||
best evidence of what this board actually moves at, and a plan that ignores it is a wish.
|
||||
|
||||
## Priorities
|
||||
|
||||
Priority runs **1 most urgent to 5 least**, and may be unset. `worklane set <ticket>
|
||||
--priority <n>` is the only writer.
|
||||
|
||||
Priority is relative. A ticket is never urgent by itself, it is urgent above something
|
||||
else, so every proposed change has to name what it now sits above and below. "This looks
|
||||
important" is not a reason; "this blocks three tickets that are all dated before it" is.
|
||||
|
||||
What to look for:
|
||||
|
||||
- **A blocker priced below what it blocks.** Read the Relations. A ticket that others are
|
||||
`blocked by` cannot be less urgent than the most urgent of them, or the board is asking
|
||||
for work in an order it will not allow.
|
||||
- **A flat board.** If almost everything is 3, the field is carrying no information and
|
||||
the answer is not to renumber everything at once. Propose the few that are genuinely 1
|
||||
and the few that are genuinely 5, and leave the middle alone.
|
||||
- **Too many 1s.** If everything is urgent, nothing is. Say how many there are before
|
||||
proposing another.
|
||||
- **A low priority already in `committed`.** Either the priority is wrong or starting it
|
||||
was, and which one it is decides whether the fix is a `set` or a conversation.
|
||||
- **A priority nobody has touched since the ticket was filed.** It is the filer's first
|
||||
guess, not a decision. That is the pile worth reading.
|
||||
|
||||
## Due dates
|
||||
|
||||
`worklane set <ticket> --due 2026-08-29`, format `YYYY-MM-DD`.
|
||||
|
||||
A value that is not a real calendar date in that exact form is refused before anything
|
||||
is written, so a typo costs nothing. `2026-8-9` is refused too: the padding is part of
|
||||
the format. What is still true is that a date, once written, **cannot be cleared**, only
|
||||
replaced by another date, so a plan applied to the wrong ticket has no undo.
|
||||
|
||||
Ask the system what today is rather than assuming it. A plan built on a guessed date is
|
||||
wrong by however much the guess was wrong.
|
||||
|
||||
The rules a dating plan has to keep:
|
||||
|
||||
- **Nothing is dated before the ticket it is blocked by.** Read the Relations first and
|
||||
date blockers ahead of their dependents. A dependent dated before its blocker is a date
|
||||
`mv` will refuse to honour anyway.
|
||||
- **A blocker left undated makes its dependent's date a fiction.** Either date both or
|
||||
neither.
|
||||
- **Date what fits, not what exists.** Ask how much capacity the week holds, or take the
|
||||
answer from what `done` shows the board finishing in a comparable stretch. Dating the
|
||||
whole backlog produces a board where every ticket is late, which is the same as no
|
||||
dates at all.
|
||||
- **Do not date `done`.** It is finished; a date on it is noise in every listing.
|
||||
- Leave the rest unset. An unset due date is honest about what has not been planned.
|
||||
|
||||
## Tags
|
||||
|
||||
`worklane set <ticket> --tags bug,cli` is the writer, and it **replaces the whole
|
||||
field**. Restate every tag the ticket should keep, or the ones you left out are gone.
|
||||
This is the single most destructive thing in this document.
|
||||
|
||||
Derive the vocabulary from the board rather than inventing one. Read the tickets, count
|
||||
what is actually used, and show the count before proposing anything. What to report:
|
||||
|
||||
- **Two spellings of one idea.** `bug` and `bugfix`, `tui` and `ui`. Pick the one already
|
||||
used more and say so.
|
||||
- **A tag used exactly once.** Either it is the start of a category and should be applied
|
||||
to its siblings, or it is a private note and should go. Do not leave it as it is without
|
||||
saying which.
|
||||
- **A tag that restates a field.** A `p1` tag beside a Priority field, an `open` tag
|
||||
beside a Status, an owner's name as a tag. The field is the writer; the tag is a copy
|
||||
that will disagree with it. This board already made that mistake once with priority and
|
||||
undid it deliberately.
|
||||
- **An untagged ticket** in a board where everything else is tagged. It is invisible to
|
||||
every question asked by tag, `worklane ls --tag` included.
|
||||
|
||||
Tags are for kind, not for state and not for goal. State is the status directory and the
|
||||
fields; a goal is a campaign.
|
||||
|
||||
## Campaigns
|
||||
|
||||
```
|
||||
worklane campaign ls
|
||||
worklane campaign show "v1 release"
|
||||
worklane campaign add --title "..." --description "..."
|
||||
worklane assign "v1 release" 1b78a24
|
||||
```
|
||||
|
||||
A campaign is the tickets that have to be finished **together** for one outcome. The test
|
||||
is whether you can name the outcome in a single line without listing the members. "The
|
||||
tui is usable on a narrow terminal" is a campaign. "The tui tickets" is a tag.
|
||||
|
||||
- **Do not group by tag.** Ten tickets tagged `bug` share a kind, not a goal, and putting
|
||||
them in a container says nothing that the tag did not already say.
|
||||
- **Check what exists first.** `campaign ls` before proposing a new one, or you will
|
||||
propose a second container for a goal that already has one.
|
||||
- **A ticket is in at most one campaign**, and `assign` moves it rather than adding a
|
||||
second. So two proposed campaigns that overlap are really one proposal to take members
|
||||
out of the other, and it has to say so.
|
||||
- **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`.
|
||||
|
||||
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.
|
||||
|
||||
## What a planner does not touch
|
||||
|
||||
- **Descriptions, acceptance criteria and implementation plans.** They are the ticket
|
||||
author's account of the work, and grooming is about how the work is ordered, not what
|
||||
it is. Something wrong in there is a comment on that ticket.
|
||||
- **Status.** `mv` belongs to whoever does the work. A plan that moves tickets between
|
||||
columns is reporting progress that did not happen.
|
||||
- **Owner.** `chown` records a commitment a person made. Propose it, do not write it,
|
||||
unless you were asked to assign the work.
|
||||
- **New tickets.** Grooming is about what is on the board. Something genuinely missing is
|
||||
worth filing, by the rules in the `worklane` skill, but say it is a new ticket rather
|
||||
than folding it into a grooming sweep.
|
||||
@@ -0,0 +1,162 @@
|
||||
---
|
||||
name: worklane-review
|
||||
description: Review a finished worklane ticket against the code that claims to close it, and record the verdict on the board. Use when asked to review a ticket, to check whether a ticket is really done, or to verify that an implementation matches its acceptance criteria, whether the ticket is named by id, by title or as "the one in reviewing". Covers finding the commits, judging each criterion against the code, and what a reviewer may and may not write back to the board.
|
||||
---
|
||||
|
||||
# Reviewing a worklane ticket
|
||||
|
||||
For "review ticket 1b78a24", "is 4179958 actually done", "check the work on the tui
|
||||
scroll ticket". The subject is one ticket. Reviewing a diff that no ticket claims is
|
||||
ordinary code review and not this job.
|
||||
|
||||
This document is the review only. The CLI itself, the statuses, how a ticket is
|
||||
addressed and the argument traps, is the `worklane` skill; read that too.
|
||||
|
||||
## What a review produces
|
||||
|
||||
Three things, in this order, and nothing else:
|
||||
|
||||
1. **One comment** on the ticket, in the structure below.
|
||||
2. **Unticked criteria**, for the ones the code does not actually meet.
|
||||
3. **Appended criteria**, for work the review found that the ticket never asked for.
|
||||
|
||||
You do not tick a criterion, you do not move the ticket, and you do not fix the code.
|
||||
Each of those has a reason, given where it comes up.
|
||||
|
||||
## 1. Read the ticket before the code
|
||||
|
||||
```
|
||||
worklane show 1b78a24
|
||||
```
|
||||
|
||||
All of it, comments included. The description says what was wrong, the criteria say what
|
||||
"done" was supposed to mean, the plan says what someone intended to do about it, and the
|
||||
comments are where the intent moved after filing. A criterion that contradicts a comment
|
||||
is one of the more useful things you can find: it means the ticket was not updated when
|
||||
the plan changed, and one of the two is now lying to whoever reads the board.
|
||||
|
||||
Read the Relations too. A `blocked by` that is not done, or a `regression of`, changes
|
||||
what the change was allowed to do and what the review has to check twice.
|
||||
|
||||
## 2. Find the work
|
||||
|
||||
The board stores no branch and no sha, so the link from ticket to code has to be found.
|
||||
Check the repo's own commit convention first, in its `AGENTS.md`, `CLAUDE.md` or in
|
||||
`git log`, rather than assuming the id appears in the message at all.
|
||||
|
||||
```
|
||||
git log --all --oneline --grep 1b78a24 # where commits name the ticket
|
||||
git log --oneline -20 # where they do not, read the recent ones
|
||||
git branch -a --list '*scroll*' # a branch named after the work
|
||||
git diff main...HEAD # the whole change, once you have both ends
|
||||
```
|
||||
|
||||
Widen it with the files the description names, since a ticket that names
|
||||
`src/tui.rs` is reviewable through `git log -p -- src/tui.rs` even when no commit
|
||||
message mentions it.
|
||||
|
||||
**If nothing names the ticket, that is the finding.** Do not review the working tree on
|
||||
the assumption that whatever is uncommitted must be the work, and do not report a pass
|
||||
you could not check. Comment what you searched for and stop: a ticket sitting in
|
||||
`reviewing` with no traceable work is exactly what a reviewer is for.
|
||||
|
||||
## 3. Judge each criterion separately
|
||||
|
||||
One criterion at a time, by its number from `show`, and each against **the code**. Never
|
||||
against the implementation plan: the plan is what someone meant to do, and a review that
|
||||
confirms the plan was followed cannot notice that following it was not enough.
|
||||
|
||||
Read the code the criterion is about, not only the lines the diff touched. A criterion
|
||||
that the diff satisfies and the surrounding code defeats is not met.
|
||||
|
||||
Give each one a verdict and its evidence, a file and a line:
|
||||
|
||||
- **met** - and where.
|
||||
- **not met** - and what is missing.
|
||||
- **cannot tell** - and what would settle it. This is a real verdict. Use it instead of
|
||||
guessing, and say what you would have to run or read.
|
||||
|
||||
Run whatever the repo runs, its test suite and its linter. A suite that fails is not a
|
||||
criterion, but no criterion is met while it fails.
|
||||
|
||||
Then the two questions the criteria cannot ask themselves:
|
||||
|
||||
- **What did this change break that no criterion covers?** Silent behaviour changes,
|
||||
a message or exit code something else reads, an edge case the ticket never named.
|
||||
- **What did the ticket never think of?** That is what you append in step 5.
|
||||
|
||||
## 4. Write one comment
|
||||
|
||||
One call, one comment. Not one per criterion: the board renders comments in the order
|
||||
they were written, and a review split over eight of them cannot be read as a verdict.
|
||||
|
||||
```
|
||||
worklane comment 1b78a24 "**Verdict**: two criteria unmet, the scroll clamp is off by the header
|
||||
|
||||
**Work reviewed**: 4edc7fa, 6d327df on master
|
||||
|
||||
**Criteria**
|
||||
1. met - PageUp and PageDown reach detail_scroll, src/tui.rs:412
|
||||
2. not met - the footer still lists the arrow keys, src/tui.rs:88
|
||||
3. cannot tell - no test covers a ticket longer than the viewport
|
||||
|
||||
**Findings**
|
||||
- The clamp uses the raw line count, so a wrapped ticket scrolls past its end, src/tui.rs:430
|
||||
- Unticked criterion 2 accordingly
|
||||
|
||||
**Recommendation**: back to committed, the clamp is the ticket's own subject"
|
||||
```
|
||||
|
||||
Keep the structure, drop the sections that have nothing in them. `**Work reviewed**` is
|
||||
never empty: it holds the shas, the branch, or what you searched for and did not find.
|
||||
Write for the person who has to act on it, so every finding says where it is.
|
||||
|
||||
The comment body takes a leading hyphen without being parsed as a flag, so a finding can
|
||||
quote `--force` literally. A body of exactly `--` needs its own separator.
|
||||
|
||||
## 5. Write the verdict back to the ticket
|
||||
|
||||
```
|
||||
worklane uncheck 1b78a24 2 5
|
||||
worklane append 1b78a24 --acceptance "The footer lists only the keys that are bound"
|
||||
```
|
||||
|
||||
Untick every criterion you found unmet, by the numbers `show` printed, in one call. Do
|
||||
it after the comment so there is a written reason on the board before the mark changes.
|
||||
Do not reach for `all`: a review unticks what it found unmet, and unticking the lot would
|
||||
erase the implementer's claim on the criteria you agreed with.
|
||||
|
||||
**Never tick a criterion.** A tick is the implementer's claim that something is done, and
|
||||
unticking is the review disagreeing with that claim. A reviewer that also ticks makes
|
||||
both the same mark, and the board stops recording that anyone ever disagreed. A criterion
|
||||
you found met but left unticked is a line in the comment, not a mark for you to fix.
|
||||
|
||||
Append a criterion only for work the next commit has to make true, phrased so it can be
|
||||
ticked off. Advice, praise and anything already covered by an existing criterion belong in
|
||||
the comment. An appended criterion that restates a finding just makes the ticket longer
|
||||
without making it clearer.
|
||||
|
||||
**Do not move the ticket.** `mv` belongs to whoever does the work, the same way ticking
|
||||
does. Your half is the recommendation in the comment; acting on it is theirs. A reviewer
|
||||
that reviews and closes in one breath leaves nobody to disagree with.
|
||||
|
||||
## What a reviewer does not touch
|
||||
|
||||
- **The description, plan, title, priority and tags.** Rewriting the ticket you are
|
||||
reviewing destroys the record of what was asked for, which is the only thing your
|
||||
verdict can be measured against. Say it in the comment.
|
||||
- **The code.** Even a one-line fix is a finding: whoever wrote it gets to make the
|
||||
change, and gets to keep the review that asked for it. Fix it only if you are asked to,
|
||||
and then it is a new piece of work with its own comment.
|
||||
- **Another ticket's business.** Something you found that is genuinely out of scope gets
|
||||
its own ticket, filed the way the `worklane` skill says, and
|
||||
`worklane relate <new> --relates-to <this>` so the two are findable from each other.
|
||||
|
||||
## Reviewing what is waiting
|
||||
|
||||
```
|
||||
worklane ls reviewing
|
||||
```
|
||||
|
||||
One ticket at a time, with its own comment. A single comment covering four tickets lands
|
||||
on one of them and is lost to the other three.
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
---
|
||||
name: worklane
|
||||
description: Manage tickets on a local worklane kanban board with the `worklane` CLI, backed by markdown files in a `.worklane/` directory. Use whenever you need to file, find, read, update, comment on or move a ticket, when asked what is on the board or what to pick up next, and when reporting work you are not going to do in the change at hand. Covers the four statuses, how a ticket is addressed, what belongs in each section, and the argument traps that silently swallow a flag.
|
||||
---
|
||||
|
||||
# worklane
|
||||
|
||||
A kanban board as files. Every ticket is one markdown file in `.worklane/<status>/`,
|
||||
named `<uuid>_<slug>.md`, and comments live in `.worklane/comments/<uuid>/`. The CLI is
|
||||
the only thing that writes there: do not hand-edit or hand-place a file, because the
|
||||
filename, the `Status` field and the directory have to agree and the commands are what
|
||||
keep them agreeing.
|
||||
|
||||
Commands walk up from the working directory to find the nearest `.worklane`, so **run
|
||||
`worklane` inside the repo the ticket belongs to**. Which directory you run it in is
|
||||
what decides which board the ticket lands on.
|
||||
|
||||
`worklane` with no subcommand opens an interactive board and needs a terminal. It is for
|
||||
a person, not for you: it takes over the screen and does not return until quit.
|
||||
|
||||
## The flow
|
||||
|
||||
`backlog` → `committed` → `reviewing` → `done`
|
||||
|
||||
**Move the ticket as you work it, not afterwards.** `worklane mv <id> --status committed`
|
||||
before writing any code, and `--status reviewing` once it is done and the tests pass. The
|
||||
board is then true while the work is in progress, not only after it lands, which is the
|
||||
whole point of having a `committed` column.
|
||||
|
||||
Only one stage at a time is allowed, so a ticket left in `backlog` until the end cannot
|
||||
go straight to `reviewing` and has to be walked through `committed` anyway. Doing it up
|
||||
front is the same two commands in a more useful order. `-f` allows a backward or
|
||||
skipping move, for correcting a mistake.
|
||||
|
||||
A move is also refused while the ticket is blocked by one that is not done yet, see
|
||||
[Relating tickets](#relating-tickets).
|
||||
|
||||
`mv` stamps the time as it goes: `Committed On`, `Submitted On` and `Completed On`, one
|
||||
field for the status the ticket is in now, shown by `show` among the rest of the
|
||||
metadata. Only the current one is kept, so the stamp says how long the ticket has been
|
||||
where it is, not how long each earlier stage took. Nothing else writes them, and moving
|
||||
a ticket back removes the stamp of the status it left.
|
||||
|
||||
## Reading the board
|
||||
|
||||
```
|
||||
worklane ls # every status, counts then tickets
|
||||
worklane ls backlog # one status
|
||||
worklane ls --priority 1 # only the most urgent
|
||||
worklane ls --tag bug # only the tickets carrying that tag
|
||||
worklane show 1b78a24 # one ticket, body and comments
|
||||
```
|
||||
|
||||
`ls` prints a seven-character id per ticket. That is what you address it by.
|
||||
|
||||
`worklane ls --ids` prints the same tickets as an id, a tab and a title, one per line and
|
||||
unstyled, with done included and the filters still applying. That is the form to parse
|
||||
when you want the ids themselves: `worklane ls --ids | cut -f1`. The decorated listing is
|
||||
for reading, not for cutting up.
|
||||
|
||||
The filters compose in any combination, with each other and with the status positional:
|
||||
`worklane ls backlog --tag bug --priority 1`. `--tag` takes one tag and matches it
|
||||
against the whole values of the comma-separated `Tags` field, case sensitively, so
|
||||
`--tag bug` finds neither a ticket tagged `bugfix` nor one tagged `Bug`. A ticket with no
|
||||
tags matches none. A tag nothing carries lists nothing rather than failing, so when a
|
||||
listing comes back empty check the spelling against a ticket you know is tagged.
|
||||
|
||||
## Working a ticket
|
||||
|
||||
```
|
||||
worklane mv 1b78a24 --status committed
|
||||
worklane check 1b78a24 3 # tick acceptance criterion 3
|
||||
worklane check 1b78a24 "the footer describes" # or a substring of it
|
||||
worklane check 1b78a24 1 3 "the footer" # several in one call
|
||||
worklane check 1b78a24 all # every criterion on the ticket
|
||||
worklane uncheck 1b78a24 3
|
||||
worklane comment 1b78a24 "Found the cause: the offset was never passed to the widget."
|
||||
worklane mv 1b78a24 --status reviewing
|
||||
```
|
||||
|
||||
Criteria are numbered by `show`. With no criterion given, `check` prompts when there
|
||||
is a terminal and otherwise fails with the numbered list, so **always pass the criteria
|
||||
when you are not sitting at a prompt**.
|
||||
|
||||
One call takes as many terms as you like, mixing numbers and substrings, and `all` stands
|
||||
for every criterion on the ticket. Use it when the work is done: it is one write instead
|
||||
of one per box. `all` is a keyword, checked before the text, so a criterion whose own
|
||||
words include "all" is reached by its number or by a longer substring.
|
||||
|
||||
**Every term is resolved before anything is written.** One term that matches nothing, or
|
||||
matches more than one criterion, refuses the whole call and names that term, so the ticket
|
||||
is never left half-marked. A criterion already in the state you asked for is reported
|
||||
unchanged rather than refused, and a call that would change nothing writes nothing. Both
|
||||
apply to `uncheck` exactly as they do to `check`.
|
||||
|
||||
## Filing a ticket
|
||||
|
||||
```
|
||||
worklane add \
|
||||
--title "The tui detail view cannot scroll" \
|
||||
--description "Opening a ticket and pressing down moves to the next one instead." \
|
||||
--description "" \
|
||||
--description "Up and down are bound to select_card unconditionally, src/main.rs." \
|
||||
--acceptance "PageUp and PageDown scroll the detail view" \
|
||||
--acceptance "The footer describes the keys that exist" \
|
||||
--plan "Add a scroll offset to Board and pass it to Paragraph::scroll" \
|
||||
--plan "Clamp against the wrapped line count, not the raw line count" \
|
||||
--priority 2 --tags bug,tui
|
||||
```
|
||||
|
||||
`add` always lands in `backlog`. Nothing is created without `--title`.
|
||||
|
||||
- **`--description`** is the case for the ticket: the symptom, then what is actually
|
||||
wrong, naming the files, functions and settings involved. Repeat the flag for more
|
||||
lines; an empty `--description ""` between two values is a paragraph break.
|
||||
- **`--acceptance`** takes one criterion per flag, each a statement that can be
|
||||
checked off as true or false.
|
||||
- **`--plan`** takes one step per flag, numbered for you.
|
||||
- **`--priority`** runs 1 (most urgent) to 5 (least), and is left unset if omitted.
|
||||
- **`--due`** takes `YYYY-MM-DD` and nothing else. Anything that is not a real calendar
|
||||
date in that exact form, `2026-8-9` and `2026-02-30` included, is a usage error with
|
||||
nothing written. The same parser guards `set --due`.
|
||||
|
||||
Editing afterwards, on a ticket in any status:
|
||||
|
||||
```
|
||||
worklane set 1b78a24 --priority 1 # replace a field
|
||||
worklane set 1b78a24 --title "A better title" # renames the file, keeps the uuid
|
||||
worklane append 1b78a24 --acceptance "One more criterion"
|
||||
worklane append 1b78a24 --description "What was learned since."
|
||||
worklane chown alice 1b78a24 # hand the ticket to someone
|
||||
```
|
||||
|
||||
`set` replaces, `append` adds. Neither has `--owner` or `--status`: owner is `chown`'s
|
||||
and status is `mv`'s, so each field has exactly one writer. A field set to the value it
|
||||
already holds is reported unchanged and nothing is written.
|
||||
|
||||
`chown` takes the **user first and the ticket second**, after Unix `chown`, which is the
|
||||
one command here that does not start with the ticket. The user is free text and is
|
||||
checked against nothing. Swap the two and the call fails, because the username has to
|
||||
resolve as a ticket.
|
||||
|
||||
`worklane init` creates `.worklane/` with the four status directories and the campaigns
|
||||
directory beside them, for a repo that has no board yet.
|
||||
|
||||
## Relating tickets
|
||||
|
||||
```
|
||||
worklane relate 1b78a24 --blocked-by 4179958 # this one waits on that one
|
||||
worklane relate 1b78a24 --regression-of 6d327df # this one broke that one's fix
|
||||
worklane relate 1b78a24 --relates-to 7bfb9fc # neighbours, no dependency
|
||||
```
|
||||
|
||||
One flag per kind, and each repeats. The ticket comes first and the flag says what it is
|
||||
to the target, so read the call as a sentence: `relate A --blocked-by B` means A waits
|
||||
on B. **Only one side is stored**, on the ticket you name, and `show` derives the other
|
||||
end for the ticket at the far side, so never record both directions.
|
||||
|
||||
`--blocked-by` is enforced: `mv` refuses to move a ticket while a ticket it is blocked by
|
||||
is not in `done`, whichever move it is, and names every open blocker. `-f` moves it
|
||||
anyway, beside the backward and skipping moves it already allows. The other two kinds are
|
||||
reference data and never refuse anything.
|
||||
|
||||
Recording a relation the ticket already holds reports no change. A ticket cannot relate
|
||||
to itself, and a target that later disappears shows as `_missing_` rather than silently
|
||||
going away.
|
||||
|
||||
`show` marks each row twice, kind then status. The kind is `×` for `blocked by` and
|
||||
`blocks`, `→` for `relates to`, `←` for `regression of` and `regressed by`; both
|
||||
directions of one kind carry one mark, and the label is what says which end you are on.
|
||||
The status is the target's own: `○` backlog, `◐` committed or reviewing, `●` done, and
|
||||
`?` for a target the board no longer holds. So `blocked by × ● (1b78a24)` is a blocker
|
||||
that is finished and `blocked by × ○ (1b78a24)` is one nobody has started. The board
|
||||
draws the same block.
|
||||
|
||||
Colour is what tells committed from reviewing, since both are `◐`, and **your output is a
|
||||
pipe, so you do not get the colour**. Read `◐` as under way, and if it matters which
|
||||
stage, `worklane show` on that target says so in its Status field. `●` and `○` are
|
||||
unambiguous without it, which are the two answers usually being asked for.
|
||||
|
||||
## Campaigns
|
||||
|
||||
A campaign groups the tickets that have to be finished together: a release, a migration,
|
||||
anything whose parts are separate tickets but whose goal is one thing. It is a file of
|
||||
its own under `.worklane/campaigns/`, with a title and a description, and it sits in no
|
||||
status directory. Its state is derived instead, open until every member is done, so
|
||||
there is no such thing as a done campaign holding an open ticket.
|
||||
|
||||
```
|
||||
worklane campaign add --title "v1 release" \
|
||||
--description "Everything that has to ship before the tag."
|
||||
worklane campaign ls # every campaign and how far it has got
|
||||
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
|
||||
```
|
||||
|
||||
`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.
|
||||
|
||||
A ticket is in at most one campaign, so assigning one that already belongs somewhere
|
||||
moves it rather than adding a second. Assigning it to the campaign it already names
|
||||
reports no change and writes nothing.
|
||||
|
||||
`campaign show` lists done members too, unlike `ls`, which leaves the done column out of
|
||||
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
|
||||
so, and there is no way to move a campaign, because it has no status to move.
|
||||
|
||||
## Search the backlog before filing
|
||||
|
||||
Run `worklane ls` in the directory the ticket would land in and look for the same issue,
|
||||
including tickets already committed, in review or done. Search by the symptom and by the
|
||||
name of the function or setting involved, not only by your own phrasing of the title: an
|
||||
existing ticket will have been written from a different angle.
|
||||
|
||||
- Already there and still open: add what you learned as a comment, not a second ticket.
|
||||
- Already there and closed, but the issue is back: file a **new** ticket naming the old
|
||||
id, and record it with `relate <new> --regression-of <old>`. There is no way to reopen
|
||||
one, and moving a done ticket back would destroy the record of the original fix.
|
||||
- Related but not the same: file it, and record it with `relate <new> --relates-to <old>`
|
||||
rather than only mentioning the id in prose.
|
||||
|
||||
## Shell completions
|
||||
|
||||
```
|
||||
worklane completions fish > ~/.config/fish/completions/worklane.fish
|
||||
```
|
||||
|
||||
For the person's shell, not for you, and `bash`, `zsh`, `elvish` and `powershell` are
|
||||
there too. Only fish completes ticket ids, which it does by running `worklane ls --ids`,
|
||||
so a stale binary on PATH completes nothing and the fix is to reinstall it.
|
||||
|
||||
## Addressing a ticket
|
||||
|
||||
Every command that takes a ticket accepts, in this order of precedence:
|
||||
|
||||
1. a UUID prefix, from four characters up
|
||||
2. a substring of the title
|
||||
3. a substring of the filename
|
||||
|
||||
The first tier that matches anything wins outright; the later tiers are not consulted.
|
||||
This matters because ticket titles quote other tickets' ids, and a flat search reported
|
||||
an exact id as ambiguous against whichever title mentioned it. An ambiguous match prints
|
||||
the candidates and exits 1 rather than guessing.
|
||||
|
||||
## Traps
|
||||
|
||||
- **Prose arguments accept a leading hyphen**: `--title`, `--description`,
|
||||
`--acceptance`, `--plan` and the `comment` body. A criterion reading
|
||||
`--print is supported` is stored, not parsed as a flag. The cost is that a genuinely
|
||||
mistyped flag there lands as content instead of failing, so read back what you wrote
|
||||
with `worklane show`.
|
||||
- `--due`, `--priority`, `--tags`, `--owner` and `--status` do *not* accept one, so a
|
||||
mistyped flag on those is a usage error and nothing is written.
|
||||
- A ticket argument that starts with a hyphen needs the flags first and a separator:
|
||||
`worklane mv --status committed -- -leading-title`.
|
||||
- A comment body of exactly `--` needs its own separator:
|
||||
`worklane comment 1b78a24 -- --`.
|
||||
- An empty value for a scalar is a usage error. Clearing a field back to unset is not
|
||||
supported yet.
|
||||
- Piping is safe: `worklane ls | head -3` exits on the closed pipe instead of panicking.
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
//! Campaigns: the container for tickets that have to be finished together.
|
||||
//!
|
||||
//! A campaign is a file of its own under `.worklane/campaigns/`, holding a title, a
|
||||
//! description and metadata. It has no status directory and never sits in one. Its
|
||||
//! state is derived instead: open until every member is done. Deriving it means there
|
||||
//! is no such thing as a done campaign holding an open ticket, and no second
|
||||
//! forward-only ruleset to reason about beside `mv`'s.
|
||||
//!
|
||||
//! Membership is one field on the *member*, `Campaign` in the ticket Metadata, written
|
||||
//! only by `assign`. The member list is deliberately not stored on the campaign: that
|
||||
//! would put membership in two places, and would make one file that every assignment
|
||||
//! edits, which is contended the moment two agents share a board.
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::util::*;
|
||||
|
||||
/// Where campaigns live, beside the status directories rather than among them.
|
||||
pub const CAMPAIGNS_DIR: &str = "campaigns";
|
||||
|
||||
pub fn campaigns_dir(worklane_dir: &Path) -> PathBuf {
|
||||
worklane_dir.join(CAMPAIGNS_DIR)
|
||||
}
|
||||
|
||||
/// The campaigns directory, created if the board predates it.
|
||||
///
|
||||
/// `init` writes it for a new board, but every board made before campaigns existed has
|
||||
/// none, and refusing to file a campaign there would mean a `worklane init` over a live
|
||||
/// board just to get a directory.
|
||||
pub fn ensure_campaigns_dir(worklane_dir: &Path) -> Result<PathBuf> {
|
||||
let dir = campaigns_dir(worklane_dir);
|
||||
|
||||
fs::create_dir_all(&dir)
|
||||
.map_err(|e| anyhow!("Could not create {}: {}", dir.display(), e))?;
|
||||
|
||||
Ok(dir)
|
||||
}
|
||||
|
||||
/// A campaign as it comes off disk.
|
||||
pub struct Campaign {
|
||||
pub uuid: String,
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
/// The campaigns directory as [`resolve_in`] takes it.
|
||||
///
|
||||
/// The name is empty because a campaign has no status: it is what makes the ambiguity
|
||||
/// listing print an id and a title with no bracket after it.
|
||||
fn campaign_paths(worklane_dir: &Path) -> Vec<(String, PathBuf)> {
|
||||
vec![(String::new(), campaigns_dir(worklane_dir))]
|
||||
}
|
||||
|
||||
/// A campaign by the same three tiers a ticket resolves by, scoped to its own
|
||||
/// directory.
|
||||
///
|
||||
/// The tiers are [`resolve_in`]'s, not a second copy: a campaign is addressed the way
|
||||
/// everything else here is, and two resolvers would be two sets of precedence rules to
|
||||
/// keep in step.
|
||||
pub fn resolve_campaign(search: &str, worklane_dir: &Path) -> Result<Campaign> {
|
||||
let mut matches = resolve_in(search, &campaign_paths(worklane_dir))?;
|
||||
|
||||
if matches.is_empty() {
|
||||
return Err(anyhow!("No campaign found matching '{}'", search));
|
||||
}
|
||||
|
||||
if matches.len() > 1 {
|
||||
return Err(ambiguous("campaign", search, &matches));
|
||||
}
|
||||
|
||||
let found = matches.remove(0);
|
||||
let uuid = parse_ticket_field(&found.content, "ID");
|
||||
|
||||
if uuid.trim().is_empty() || is_unknown_value(&uuid) {
|
||||
return Err(anyhow!(
|
||||
"Campaign '{}' has no ID field, so nothing can be assigned to it",
|
||||
found.title
|
||||
));
|
||||
}
|
||||
|
||||
Ok(Campaign {
|
||||
uuid,
|
||||
title: found.title,
|
||||
content: found.content,
|
||||
})
|
||||
}
|
||||
|
||||
/// The title of the campaign a search names, for a caller that only needs to say so.
|
||||
///
|
||||
/// Used by `resolve_ticket` to explain a search that names a campaign rather than a
|
||||
/// ticket. Deliberately swallows both failures: nothing matched and too much matched
|
||||
/// both mean "this is not the explanation", and an error here would replace a clear
|
||||
/// "no ticket found" with a complaint about a directory the caller never mentioned.
|
||||
pub fn campaign_named(search: &str, worklane_dir: &Path) -> Option<String> {
|
||||
resolve_campaign(search, worklane_dir)
|
||||
.ok()
|
||||
.map(|campaign| campaign.title)
|
||||
}
|
||||
|
||||
/// Every campaign on the board, read in one pass.
|
||||
///
|
||||
/// 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.
|
||||
pub struct CampaignIndex {
|
||||
campaigns: Vec<Campaign>,
|
||||
}
|
||||
|
||||
impl CampaignIndex {
|
||||
pub fn load(worklane_dir: &Path) -> Result<Self> {
|
||||
let dir = campaigns_dir(worklane_dir);
|
||||
let mut campaigns = Vec::new();
|
||||
|
||||
// A board with no campaigns directory has no campaigns, which is not an error:
|
||||
// every board made before campaigns existed is in that state.
|
||||
if !dir.exists() {
|
||||
return Ok(Self { campaigns });
|
||||
}
|
||||
|
||||
for entry in fs::read_dir(&dir)?.filter_map(|e| e.ok()) {
|
||||
let path = entry.path();
|
||||
if !path.extension().is_some_and(|e| e == "md") {
|
||||
continue;
|
||||
}
|
||||
let Ok(content) = fs::read_to_string(&path) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
campaigns.push(Campaign {
|
||||
uuid: parse_ticket_field(&content, "ID"),
|
||||
title: heading_title(&content),
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
||||
// By title, so a listing does not depend on the order the directory hands its
|
||||
// entries back in.
|
||||
campaigns.sort_by_key(|campaign| campaign.title.to_lowercase());
|
||||
Ok(Self { campaigns })
|
||||
}
|
||||
|
||||
/// The campaign carrying `uuid`, or nothing when the board no longer has it.
|
||||
pub fn get(&self, uuid: &str) -> Option<&Campaign> {
|
||||
self.campaigns.iter().find(|campaign| campaign.uuid == uuid)
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &Campaign> {
|
||||
self.campaigns.iter()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.campaigns.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// The Campaign field as it reads, or empty for a ticket in no campaign.
|
||||
///
|
||||
/// A uuid no campaign carries renders as `_missing_`, the way a dangling relation
|
||||
/// target does, rather than as the bare value the file stores: the value is a full
|
||||
/// uuid, so showing it raw is thirty-six characters that say nothing about what is
|
||||
/// gone.
|
||||
pub fn campaign_cell(content: &str, index: &CampaignIndex, colored: bool) -> String {
|
||||
let Some(uuid) = parse_campaign(content) else {
|
||||
return String::new();
|
||||
};
|
||||
|
||||
reference_cell(
|
||||
&uuid,
|
||||
index.get(&uuid).map(|campaign| campaign.title.as_str()),
|
||||
colored,
|
||||
)
|
||||
}
|
||||
|
||||
/// The parts [`content_trim`] cannot render from the ticket file alone.
|
||||
///
|
||||
/// Both halves read the tree beside the ticket, so they are gathered in one place
|
||||
/// rather than at each call site.
|
||||
pub fn resolved_for(content: &str, worklane_dir: &Path, colored: bool) -> Result<Resolved> {
|
||||
Ok(Resolved {
|
||||
relations: relations_for(content, worklane_dir)?,
|
||||
campaign: campaign_cell(content, &CampaignIndex::load(worklane_dir)?, colored),
|
||||
})
|
||||
}
|
||||
|
||||
/// The members of a campaign, grouped by status in flow order.
|
||||
///
|
||||
/// Read through `collect_ticket_items`, the source `ls` and the board already use, so
|
||||
/// there is no second parser and the rows print the way every other listing does.
|
||||
/// Empty groups are kept: a campaign's shape is the four statuses, and a caller that
|
||||
/// wants only the filled ones can say so.
|
||||
pub fn members(worklane_dir: &Path, uuid: &str) -> Result<Vec<(&'static str, Vec<TicketItem>)>> {
|
||||
let mut grouped = Vec::new();
|
||||
|
||||
for status in status_dirs() {
|
||||
let status_path = worklane_dir.join(status);
|
||||
let items = match status_path.exists() {
|
||||
true => collect_ticket_items(&status_path)?,
|
||||
false => Vec::new(),
|
||||
};
|
||||
|
||||
grouped.push((
|
||||
status,
|
||||
items
|
||||
.into_iter()
|
||||
.filter(|item| item.campaign.as_deref() == Some(uuid))
|
||||
.collect(),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(grouped)
|
||||
}
|
||||
|
||||
/// How far a campaign has got: members done against members held.
|
||||
pub struct Standing {
|
||||
pub done: usize,
|
||||
pub total: usize,
|
||||
}
|
||||
|
||||
impl Standing {
|
||||
pub fn of(grouped: &[(&'static str, Vec<TicketItem>)]) -> Self {
|
||||
Self {
|
||||
done: grouped
|
||||
.iter()
|
||||
.filter(|(status, _)| *status == DONE)
|
||||
.map(|(_, items)| items.len())
|
||||
.sum(),
|
||||
total: grouped.iter().map(|(_, items)| items.len()).sum(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The count as it reads, or `no members` for a campaign nothing has been filed
|
||||
/// against.
|
||||
pub fn label(&self) -> String {
|
||||
match self.total {
|
||||
0 => "no members".to_string(),
|
||||
total => format!("{}/{} done", self.done, total),
|
||||
}
|
||||
}
|
||||
|
||||
/// A campaign is done when it holds members and every one of them is done.
|
||||
///
|
||||
/// An empty campaign is neither, hence the `None`: calling it done would make a
|
||||
/// container nothing has been filed against the most complete thing on the board,
|
||||
/// and calling it open would claim work that does not exist.
|
||||
pub fn state(&self) -> Option<&'static str> {
|
||||
match (self.total, self.done == self.total) {
|
||||
(0, _) => None,
|
||||
(_, true) => Some(DONE),
|
||||
(_, false) => Some("open"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The campaign file as it is written.
|
||||
///
|
||||
/// 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
|
||||
/// directory. The headings and the placeholder come from the section table in
|
||||
/// `util.rs`, so the two file formats cannot drift apart on the spelling of a heading.
|
||||
pub fn campaign_body(
|
||||
title: &str,
|
||||
description: &[String],
|
||||
id: &uuid::Uuid,
|
||||
owner: Option<&str>,
|
||||
created_at: &str,
|
||||
) -> String {
|
||||
// Joined with a single newline, so an empty value is how a caller spells a
|
||||
// paragraph break, exactly as it is for a ticket.
|
||||
let description = trim_blank_ends(description);
|
||||
let description_text = match description.is_empty() {
|
||||
true => DESCRIPTION.placeholder.to_string(),
|
||||
false => description.join("\n"),
|
||||
};
|
||||
|
||||
format!(
|
||||
"# {title}\n\
|
||||
\n\
|
||||
{description_heading}\n\
|
||||
{description_text}\n\
|
||||
\n\
|
||||
{metadata_heading}\n\
|
||||
\n\
|
||||
- **ID**: {id}\n\
|
||||
- **Owner**: {owner}\n\
|
||||
- **Created At**: {created_at}\n\
|
||||
",
|
||||
description_heading = DESCRIPTION.heading,
|
||||
metadata_heading = METADATA_HEADING,
|
||||
owner = owner.unwrap_or("_Not set_"),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//! Putting text on the clipboard of whatever terminal is drawing the board.
|
||||
//!
|
||||
//! OSC 52, written by hand, and the reasoning is in AGENTS.md under The Copy Key. The
|
||||
//! short of it: the board is often being read over ssh, and an escape sequence is the
|
||||
//! only one of the three ways that crosses the connection. crossterm 0.28 is what
|
||||
//! ratatui 0.29 pins and it ships no clipboard command, so the sequence and the base64
|
||||
//! it carries are written here rather than pulled in.
|
||||
//!
|
||||
//! The honest limit is that a terminal which ignores OSC 52 ignores it silently: what
|
||||
//! this reports is whether the sequence was written, not whether it was honoured.
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
/// Ask the terminal to put `text` on the system clipboard.
|
||||
///
|
||||
/// `52;c` is the clipboard proper rather than `p`, the X11 primary selection, because
|
||||
/// this is for pasting into a command line with ctrl-shift-v or cmd-v. Terminated with
|
||||
/// BEL rather than ST: both are accepted, and BEL is what tmux's `set-clipboard`
|
||||
/// documents and what every emulator that implements this at all takes.
|
||||
///
|
||||
/// Written straight to stdout, which is where ratatui's own frames go, and flushed
|
||||
/// before returning so a failure belongs to this call rather than to the next draw.
|
||||
pub fn copy(text: &str) -> Result<()> {
|
||||
let mut out = std::io::stdout();
|
||||
write!(out, "\x1b]52;c;{}\x07", base64(text.as_bytes()))
|
||||
.and_then(|()| out.flush())
|
||||
.context("could not write to the terminal")
|
||||
}
|
||||
|
||||
/// Standard base64, the alphabet OSC 52 requires, padding included.
|
||||
///
|
||||
/// Twenty lines against a dependency: the only thing encoded here is a seven-character
|
||||
/// id, and the crate would be carried for its own sake.
|
||||
fn base64(bytes: &[u8]) -> String {
|
||||
const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
let mut out = String::with_capacity(bytes.len().div_ceil(3) * 4);
|
||||
for chunk in bytes.chunks(3) {
|
||||
// The missing bytes of a short chunk read as zero, and the characters they
|
||||
// would have produced are the ones that become padding below.
|
||||
let triple = chunk
|
||||
.iter()
|
||||
.chain([0u8; 2].iter())
|
||||
.take(3)
|
||||
.fold(0u32, |acc, byte| (acc << 8) | u32::from(*byte));
|
||||
|
||||
for slot in 0..4 {
|
||||
match slot <= chunk.len() {
|
||||
true => out.push(char::from(ALPHABET[(triple >> (18 - 6 * slot) & 0x3f) as usize])),
|
||||
false => out.push('='),
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// The vectors from RFC 4648, which is what a terminal decodes with. Every chunk
|
||||
/// length is in here, so the padding is covered in both of its forms.
|
||||
#[test]
|
||||
fn base64_encodes_the_rfc_vectors() {
|
||||
assert_eq!(base64(b""), "");
|
||||
assert_eq!(base64(b"f"), "Zg==");
|
||||
assert_eq!(base64(b"fo"), "Zm8=");
|
||||
assert_eq!(base64(b"foo"), "Zm9v");
|
||||
assert_eq!(base64(b"foob"), "Zm9vYg==");
|
||||
assert_eq!(base64(b"fooba"), "Zm9vYmE=");
|
||||
assert_eq!(base64(b"foobar"), "Zm9vYmFy");
|
||||
}
|
||||
|
||||
/// What actually goes on the wire for a short id, which is the whole use.
|
||||
#[test]
|
||||
fn base64_encodes_a_short_id() {
|
||||
assert_eq!(base64(b"0546fc5"), "MDU0NmZjNQ==");
|
||||
}
|
||||
|
||||
/// The high bits reach the end of the alphabet, which an off-by-one in the shift
|
||||
/// would miss entirely on ascii input.
|
||||
#[test]
|
||||
fn base64_reaches_the_whole_alphabet() {
|
||||
assert_eq!(base64(&[0xff, 0xff, 0xff]), "////");
|
||||
assert_eq!(base64(&[0xfb, 0xff, 0xfe]), "+//+");
|
||||
assert_eq!(base64(&[0x00, 0x00, 0x00]), "AAAA");
|
||||
}
|
||||
}
|
||||
+415
-45
@@ -2,7 +2,9 @@ use clap::Parser;
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use crate::util::{PRIORITY_RANGE, priority_legend};
|
||||
use chrono::NaiveDate;
|
||||
|
||||
use crate::util::{PRIORITY_RANGE, RelationKind, Status, priority_legend};
|
||||
|
||||
/// clap wants a `&str` with a long enough lifetime, and the legend is built from
|
||||
/// the same ramp the listing uses rather than spelled out a second time.
|
||||
@@ -33,60 +35,84 @@ const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", env!("WORKLANE_GI
|
||||
#[command(version = VERSION)]
|
||||
#[command(propagate_version = true)]
|
||||
pub struct Cli {
|
||||
/// Absent opens the board view, the way a bare `frig` does.
|
||||
#[command(subcommand)]
|
||||
pub command: Command,
|
||||
pub command: Option<Command>,
|
||||
}
|
||||
|
||||
/// Reject an empty value at parse time, so it lands as a usage error rather than a
|
||||
/// runtime one.
|
||||
///
|
||||
/// An empty value looks like a way to clear a field, and clearing is not supported
|
||||
/// yet. Refusing it keeps the gap visible and stops an accidentally empty variable
|
||||
/// from silently blanking a field. Only the scalars use this: for the multi-line
|
||||
/// sections an empty value is a paragraph break.
|
||||
fn non_empty(raw: &str) -> Result<String, String> {
|
||||
if raw.trim().is_empty() {
|
||||
return Err("value cannot be empty, and clearing a field is not supported yet".to_string());
|
||||
}
|
||||
|
||||
Ok(raw.to_string())
|
||||
}
|
||||
|
||||
/// Reject a due date that is not a real calendar date in the promised form.
|
||||
///
|
||||
/// At parse time, like `priority_level`, so a mistyped date is a usage error with
|
||||
/// nothing written rather than a value the board goes on showing. `--due` is one of the
|
||||
/// scalars deliberately left without `PROSE`, so this is the same bargain: nothing here
|
||||
/// holds prose, and a wrong value should stop the command.
|
||||
///
|
||||
/// **The shape is checked before chrono sees it.** `%Y-%m-%d` accepts an unpadded
|
||||
/// `2026-8-9`, which would then be stored exactly as typed and sort before `2026-10-01`
|
||||
/// in any comparison of the strings. Checking the length and the two dashes first is
|
||||
/// what lets a valid date be stored unchanged rather than normalised on the way in.
|
||||
///
|
||||
/// Strict on the way in, tolerant on the way out: `util::due_date` still cuts a
|
||||
/// datetime down to its date, because a file written before this existed, or by hand,
|
||||
/// can hold one and still has to render.
|
||||
fn iso_date(raw: &str) -> Result<String, String> {
|
||||
// An empty value keeps the message that explains why it is refused, since somebody
|
||||
// typing it is reaching for a way to clear the field rather than mistyping a date.
|
||||
non_empty(raw)?;
|
||||
|
||||
let bytes = raw.as_bytes();
|
||||
let shaped = raw.len() == 10 && bytes[4] == b'-' && bytes[7] == b'-';
|
||||
|
||||
if !shaped || NaiveDate::parse_from_str(raw, "%Y-%m-%d").is_err() {
|
||||
// Not echoing the value: clap has already printed `invalid value '...' for
|
||||
// '--due <DUE>'` above this line, and `priority_level` says its piece the same
|
||||
// way.
|
||||
return Err(
|
||||
"due date must be a real calendar date written as YYYY-MM-DD, for example 2026-08-29"
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(raw.to_string())
|
||||
}
|
||||
|
||||
/// Arguments that carry prose, and therefore have to accept a value starting with
|
||||
/// a hyphen.
|
||||
///
|
||||
/// Ticket text quotes flag names constantly, and without this a criterion reading
|
||||
/// "--print is supported" is parsed as a flag and the whole ticket is refused. The
|
||||
/// trade, spelled out in AGENTS.md: on these arguments a genuinely mistyped flag
|
||||
/// now lands as content instead of raising a usage error. That is the right way
|
||||
/// round for prose, and it is why `due`, `priority`, `tags`, `owner` and `status`
|
||||
/// are deliberately left without it.
|
||||
const PROSE: bool = true;
|
||||
|
||||
#[derive(clap::Subcommand)]
|
||||
pub enum Command {
|
||||
/// Initialize worklane in the current project
|
||||
Init,
|
||||
|
||||
/// Add a new ticket to the backlog
|
||||
Add {
|
||||
/// Ticket title
|
||||
#[arg(short, long)]
|
||||
title: String,
|
||||
|
||||
/// Ticket description. Use multiple flags to create multiline descriptions.
|
||||
#[arg(short, long)]
|
||||
description: Vec<String>,
|
||||
|
||||
/// Acceptance criteria. Accepts multiple flags, each will be interpreted as a single criterium
|
||||
#[arg(short, long)]
|
||||
acceptance: Vec<String>,
|
||||
|
||||
/// Implementation plan. Accepts multiple flags, each will be interpreted as a single step
|
||||
#[arg(short, long)]
|
||||
plan: Vec<String>,
|
||||
|
||||
/// Tags (comma-separated)
|
||||
#[arg(short = 'g', long)]
|
||||
tags: Vec<String>,
|
||||
|
||||
/// Due date (YYYY-MM-DD)
|
||||
#[arg(long)]
|
||||
due: Option<String>,
|
||||
|
||||
/// Owner
|
||||
#[arg(short, long)]
|
||||
owner: Option<String>,
|
||||
|
||||
/// Priority, 1 (most urgent) to 5 (least). Left unset if omitted.
|
||||
#[arg(long, value_parser = priority_level)]
|
||||
priority: Option<u8>,
|
||||
},
|
||||
Add(AddArgs),
|
||||
|
||||
/// List tickets, optionally filtered by status
|
||||
#[command(after_help = PRIORITY_LEGEND.as_str())]
|
||||
Ls {
|
||||
/// Filter by status (backlog, committed, reviewing, done)
|
||||
status: Option<String>,
|
||||
|
||||
/// Only show tickets at this priority, 1 (most urgent) to 5 (least)
|
||||
#[arg(long, value_parser = priority_level)]
|
||||
priority: Option<u8>,
|
||||
},
|
||||
Ls(LsArgs),
|
||||
|
||||
/// Show a ticket by UUID or title
|
||||
Show {
|
||||
@@ -99,25 +125,369 @@ pub enum Command {
|
||||
/// Ticket UUID or title
|
||||
ticket: String,
|
||||
|
||||
/// Target status (backlog, committed, reviewing, done)
|
||||
/// Target status
|
||||
#[arg(short, long)]
|
||||
status: String,
|
||||
status: Status,
|
||||
|
||||
/// Force move (allows backward or non-sequential moves)
|
||||
#[arg(short, long)]
|
||||
force: bool,
|
||||
},
|
||||
|
||||
/// Replace fields on an existing ticket
|
||||
Set(SetArgs),
|
||||
|
||||
/// Add to a section of an existing ticket
|
||||
Append(AppendArgs),
|
||||
|
||||
/// Record a relation from one ticket to another
|
||||
Relate(RelateArgs),
|
||||
|
||||
/// Change the owner of a ticket
|
||||
///
|
||||
/// User first, ticket second, after Unix `chown`. That reverses the ticket-first
|
||||
/// order `mv`, `comment` and `show` use, deliberately: the name borrows the Unix
|
||||
/// association, so the argument order borrows it too.
|
||||
///
|
||||
/// A swap is caught by resolution rather than by a check of its own. Given
|
||||
/// `chown 641e3d5 alice` the second argument has to resolve as a ticket, and a bare
|
||||
/// username usually will not, so the call fails on its own. It is silently wrong
|
||||
/// only when both arguments resolve, which needs a ticket whose title matches the
|
||||
/// username.
|
||||
Chown {
|
||||
/// New owner. Free text, like `add --owner`, checked against nothing
|
||||
#[arg(value_parser = non_empty)]
|
||||
user: String,
|
||||
|
||||
/// Ticket UUID or title
|
||||
ticket: String,
|
||||
},
|
||||
|
||||
/// Open the board view
|
||||
Tui {
|
||||
/// Projects to monitor, each resolved to the first `.worklane` at or above it.
|
||||
/// Several are shown as tabs. Defaults to the working directory
|
||||
paths: Vec<std::path::PathBuf>,
|
||||
},
|
||||
|
||||
/// Tick acceptance criteria
|
||||
Check(CheckArgs),
|
||||
|
||||
/// Untick acceptance criteria
|
||||
Uncheck(CheckArgs),
|
||||
|
||||
/// Add a comment to a ticket
|
||||
Comment {
|
||||
/// Ticket UUID or title
|
||||
ticket: String,
|
||||
|
||||
/// Comment body (required)
|
||||
#[arg(allow_hyphen_values = PROSE)]
|
||||
body: String,
|
||||
|
||||
/// Owner
|
||||
#[arg(short, long)]
|
||||
owner: Option<String>,
|
||||
},
|
||||
|
||||
/// Group tickets that have to be finished together
|
||||
Campaign {
|
||||
#[command(subcommand)]
|
||||
command: CampaignCommand,
|
||||
},
|
||||
|
||||
/// Put a ticket in a campaign
|
||||
///
|
||||
/// Campaign first, ticket second, after `chown` and for the same reason: the
|
||||
/// container is what the call is about, and the order is worth being consistent
|
||||
/// about across the two commands that name two things.
|
||||
///
|
||||
/// The only writer of the Campaign field. `add` has no `--campaign` and `set` has
|
||||
/// no `--campaign`, so the field keeps one writer the way Owner and Status do.
|
||||
Assign {
|
||||
/// Campaign UUID or title
|
||||
campaign: String,
|
||||
|
||||
/// Ticket UUID or title
|
||||
ticket: String,
|
||||
},
|
||||
|
||||
/// Print a shell completion script
|
||||
///
|
||||
/// The structure comes from the clap definition, so a flag added here appears
|
||||
/// without anyone remembering to. Fish gets a hand-written half appended for the
|
||||
/// values only the board knows, see `completions.rs`.
|
||||
Completions {
|
||||
/// fish, bash, zsh, elvish or powershell
|
||||
shell: clap_complete::Shell,
|
||||
},
|
||||
|
||||
/// Install the agent skills that teach an agent to use worklane
|
||||
///
|
||||
/// Every shipped document by default. The optional name narrows it to one, and
|
||||
/// `--print` requires it: a diff is against one document, and printing them all
|
||||
/// concatenated would only look like one.
|
||||
InstallSkill {
|
||||
/// Skill to install or print, all of them if omitted
|
||||
skill: Option<String>,
|
||||
|
||||
/// Overwrite an existing copy that has been modified
|
||||
#[arg(long)]
|
||||
force: bool,
|
||||
|
||||
/// Write it to stdout instead of installing it
|
||||
#[arg(long)]
|
||||
print: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// 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.
|
||||
#[derive(clap::Subcommand)]
|
||||
pub enum CampaignCommand {
|
||||
/// File a new campaign
|
||||
Add(CampaignAddArgs),
|
||||
|
||||
/// List campaigns with their member counts
|
||||
Ls,
|
||||
|
||||
/// Show a campaign and its members grouped by status
|
||||
Show {
|
||||
/// Campaign UUID or title
|
||||
campaign: String,
|
||||
},
|
||||
}
|
||||
|
||||
/// What a campaign holds: a title, a description and an owner.
|
||||
///
|
||||
/// Deliberately narrower than [`AddArgs`]. There are no acceptance criteria, because a
|
||||
/// campaign's definition of done is derived from its members rather than written down,
|
||||
/// 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.
|
||||
#[derive(clap::Args)]
|
||||
pub struct CampaignAddArgs {
|
||||
/// Campaign title
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub title: String,
|
||||
|
||||
/// What the campaign is for. Use multiple flags for multiline descriptions
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<String>,
|
||||
|
||||
/// Owner. Defaults to the git user
|
||||
#[arg(short, long)]
|
||||
pub owner: Option<String>,
|
||||
}
|
||||
|
||||
/// `ls` holds four filters, an output mode and nothing else, which is the boundary the
|
||||
/// Rust Style rule in AGENTS.md names: two of the filters are adjacent `Option<String>`
|
||||
/// values that a caller can swap silently, so the mode that joined them came as a
|
||||
/// struct rather than a sixth parameter, the way `add` became [`AddArgs`].
|
||||
#[derive(clap::Args)]
|
||||
pub struct LsArgs {
|
||||
/// Filter by status
|
||||
pub status: Option<Status>,
|
||||
|
||||
/// Only show tickets at this priority, 1 (most urgent) to 5 (least)
|
||||
#[arg(long, value_parser = priority_level)]
|
||||
pub priority: Option<u8>,
|
||||
|
||||
/// Only show tickets carrying this tag, matched whole
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub tag: Option<String>,
|
||||
|
||||
/// Only show the members of this campaign, by UUID or title
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub campaign: Option<String>,
|
||||
|
||||
/// Print one ticket per line as its id and title, tab separated, for a script or a
|
||||
/// completion. Done included, and the filters still apply
|
||||
#[arg(long)]
|
||||
pub ids: bool,
|
||||
}
|
||||
|
||||
/// `add` carries every field a new ticket can hold, so it is a struct rather than an
|
||||
/// inline variant: nine parameters at the call site is what `too_many_arguments` is
|
||||
/// for, and `set`, `append` and `check` already pass their arguments this way.
|
||||
///
|
||||
/// No `ArgGroup`: `--title` is required on its own, and everything else is optional
|
||||
/// because a ticket with only a title is a valid thing to file.
|
||||
#[derive(clap::Args)]
|
||||
pub struct AddArgs {
|
||||
/// Ticket title
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub title: String,
|
||||
|
||||
/// Ticket description. Use multiple flags to create multiline descriptions.
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<String>,
|
||||
|
||||
/// Acceptance criteria. Accepts multiple flags, each will be interpreted as a single criterium
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub acceptance: Vec<String>,
|
||||
|
||||
/// Implementation plan. Accepts multiple flags, each will be interpreted as a single step
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub plan: Vec<String>,
|
||||
|
||||
/// Tags (comma-separated)
|
||||
#[arg(short = 'g', long)]
|
||||
pub tags: Vec<String>,
|
||||
|
||||
/// Due date (YYYY-MM-DD)
|
||||
#[arg(long, value_parser = iso_date)]
|
||||
pub due: Option<String>,
|
||||
|
||||
/// Owner
|
||||
#[arg(short, long)]
|
||||
pub owner: Option<String>,
|
||||
|
||||
/// Priority, 1 (most urgent) to 5 (least). Left unset if omitted.
|
||||
#[arg(long, value_parser = priority_level)]
|
||||
pub priority: Option<u8>,
|
||||
}
|
||||
|
||||
/// `set` replaces a field outright. Owner is deliberately absent: `chown` owns that
|
||||
/// field, and status is `mv`'s, so no field has two writers.
|
||||
///
|
||||
/// The group makes at least one field mandatory, so a bare `worklane set <ticket>` is
|
||||
/// a usage error rather than a silent no-op.
|
||||
#[derive(clap::Args)]
|
||||
#[command(group(
|
||||
clap::ArgGroup::new("set_fields")
|
||||
.required(true)
|
||||
.multiple(true)
|
||||
.args(["title", "description", "acceptance", "plan", "tags", "due", "priority"])
|
||||
))]
|
||||
pub struct SetArgs {
|
||||
/// Ticket UUID or title
|
||||
pub ticket: String,
|
||||
|
||||
/// Replace the ticket title, renaming the file to match
|
||||
#[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
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<String>,
|
||||
|
||||
/// Replace the acceptance criteria. Repeat the flag, one criterium per value
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub acceptance: Vec<String>,
|
||||
|
||||
/// Replace the implementation plan. Repeat the flag, one step per value
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub plan: Vec<String>,
|
||||
|
||||
/// Replace the tags
|
||||
#[arg(short = 'g', long, value_parser = non_empty)]
|
||||
pub tags: Vec<String>,
|
||||
|
||||
/// Replace the due date (YYYY-MM-DD)
|
||||
///
|
||||
/// The same parser as `add`: one field, one definition of what a due date is. The
|
||||
/// planning skill sets dates through `set` rather than `add`, so validating only
|
||||
/// the one that files a ticket would leave the path that is actually used open.
|
||||
#[arg(long, value_parser = iso_date)]
|
||||
pub due: Option<String>,
|
||||
|
||||
/// Replace the priority, 1 (most urgent) to 5 (least)
|
||||
#[arg(long, value_parser = priority_level)]
|
||||
pub priority: Option<u8>,
|
||||
}
|
||||
|
||||
/// `append` only offers the sections that hold multiple lines, since appending to a
|
||||
/// scalar has no meaning.
|
||||
#[derive(clap::Args)]
|
||||
#[command(group(
|
||||
clap::ArgGroup::new("append_fields")
|
||||
.required(true)
|
||||
.multiple(true)
|
||||
.args(["description", "acceptance", "plan"])
|
||||
))]
|
||||
pub struct AppendArgs {
|
||||
/// Ticket UUID or title
|
||||
pub ticket: String,
|
||||
|
||||
/// Add a paragraph to the description. Repeat the flag for more lines within it
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<String>,
|
||||
|
||||
/// Add acceptance criteria. Repeat the flag, one criterium per value
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub acceptance: Vec<String>,
|
||||
|
||||
/// Add implementation plan steps, numbered on from the last. Repeat the flag
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub plan: Vec<String>,
|
||||
}
|
||||
|
||||
/// `relate` is the only writer of the Relations section, the way `chown` is the only
|
||||
/// writer of Owner. One flag per kind rather than a `--kind` value: the accepted kinds
|
||||
/// are then clap's business, an unknown one is a usage error, and a call reads as a
|
||||
/// sentence about the ticket it names.
|
||||
///
|
||||
/// Each flag repeats, so several relations of one kind land in a single call. The
|
||||
/// targets are ticket searches, resolved by the same three tiers every other ticket
|
||||
/// argument is, and stored as the target's uuid.
|
||||
#[derive(clap::Args)]
|
||||
#[command(group(
|
||||
clap::ArgGroup::new("relation_kinds")
|
||||
.required(true)
|
||||
.multiple(true)
|
||||
.args(["blocked_by", "regression_of", "relates_to"])
|
||||
))]
|
||||
pub struct RelateArgs {
|
||||
/// Ticket UUID or title
|
||||
pub ticket: String,
|
||||
|
||||
/// Ticket this one waits on. Its own moves are refused until the target is done
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub blocked_by: Vec<String>,
|
||||
|
||||
/// Ticket whose fix this one broke
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub regression_of: Vec<String>,
|
||||
|
||||
/// Ticket this one is merely related to. Symmetric, so it is recorded once
|
||||
#[arg(long, value_parser = non_empty)]
|
||||
pub relates_to: Vec<String>,
|
||||
}
|
||||
|
||||
impl RelateArgs {
|
||||
/// The relations asked for, one entry per kind, so the handler walks a table
|
||||
/// instead of repeating itself three times.
|
||||
pub fn requested(&self) -> [(RelationKind, &[String]); 3] {
|
||||
[
|
||||
(RelationKind::BlockedBy, &self.blocked_by),
|
||||
(RelationKind::RegressionOf, &self.regression_of),
|
||||
(RelationKind::RelatesTo, &self.relates_to),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/// `check` and `uncheck` are separate commands rather than one verb with a flag,
|
||||
/// because the two read as opposites at the call site and neither needs the other's
|
||||
/// name to make sense.
|
||||
///
|
||||
/// The criteria are optional: without any the criteria are listed and the index asked
|
||||
/// for, or, where there is no terminal to ask at, returned as an error carrying the
|
||||
/// same list.
|
||||
///
|
||||
/// Several terms in one call because finishing a ticket means ticking every box, and
|
||||
/// one invocation per box resolved the ticket and rewrote the file each time. The
|
||||
/// terms are variadic rather than a repeated flag: they address something that is
|
||||
/// already there, the way the ticket positional does, instead of carrying content the
|
||||
/// way `--acceptance` does.
|
||||
#[derive(clap::Args)]
|
||||
pub struct CheckArgs {
|
||||
/// Ticket UUID or title
|
||||
pub ticket: String,
|
||||
|
||||
/// Criterion indexes as shown by `show`, substrings of their text, or `all`. Prompts if omitted
|
||||
pub criteria: Vec<String>,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
//! Shell completions.
|
||||
//!
|
||||
//! Two halves, because neither alone is enough.
|
||||
//!
|
||||
//! `clap_complete` generates the structure (subcommands, flags, their arguments)
|
||||
//! straight from the clap definition, so a new flag never needs remembering here. But it
|
||||
//! can only offer values it knows at compile time, and the value worth completing for
|
||||
//! worklane is the ticket, which lives in the board the command is run above.
|
||||
//!
|
||||
//! So the fish output gets a hand-written block appended that asks worklane itself. That
|
||||
//! costs one `worklane ls --ids` per keypress, which measured at 2.5ms in release on a
|
||||
//! board of seventy-five tickets, comfortably below anything a person notices.
|
||||
//!
|
||||
//! The four statuses are half clap's: `Status` is a `ValueEnum`, so it emits them for
|
||||
//! `mv --status`, but the fish generator does not emit possible values for a *positional*
|
||||
//! and `ls <status>` gets nothing. Same for `completions <shell>`. So the block below
|
||||
//! lists those two, from the enums rather than by hand.
|
||||
|
||||
use std::io;
|
||||
|
||||
use clap::{CommandFactory, ValueEnum};
|
||||
use clap_complete::Shell;
|
||||
|
||||
use crate::install::SKILLS;
|
||||
use crate::util::Status;
|
||||
|
||||
/// Subcommands whose first positional is a ticket.
|
||||
///
|
||||
/// Kept honest by a test rather than by memory: a new ticket-taking subcommand that is
|
||||
/// missing here silently loses completion, which nothing else would catch.
|
||||
pub const TICKET_COMMANDS: [&str; 8] = [
|
||||
"show", "mv", "comment", "set", "append", "relate", "check", "uncheck",
|
||||
];
|
||||
|
||||
/// Subcommands whose *second* positional is the ticket, because they name two things.
|
||||
///
|
||||
/// `chown alice <ticket>` and `assign "v1 release" <ticket>`, which put the ticket
|
||||
/// second deliberately, see AGENTS.md. The first argument of each is a user or a
|
||||
/// campaign, and neither is completed.
|
||||
pub const TICKET_SECOND_COMMANDS: [&str; 2] = ["chown", "assign"];
|
||||
|
||||
/// Options whose value is a ticket, as `relate` takes three of.
|
||||
pub const TICKET_FLAGS: [&str; 3] = ["blocked-by", "regression-of", "relates-to"];
|
||||
|
||||
pub fn generate(shell: Shell, out: &mut dyn io::Write) -> io::Result<()> {
|
||||
let mut command = crate::command::Cli::command();
|
||||
clap_complete::generate(shell, &mut command, "worklane", out);
|
||||
|
||||
if shell == Shell::Fish {
|
||||
write!(out, "{}", fish_dynamic())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The dynamic half, appended to what clap generated.
|
||||
///
|
||||
/// Fish merges completions from every `complete` call, so these add to the generated
|
||||
/// rules rather than replacing them.
|
||||
fn fish_dynamic() -> String {
|
||||
let ticket_commands = TICKET_COMMANDS.join(" ");
|
||||
let ticket_second_commands = TICKET_SECOND_COMMANDS.join(" ");
|
||||
let ticket_flags = TICKET_FLAGS
|
||||
.iter()
|
||||
.map(|flag| format!("-l {flag}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ");
|
||||
let statuses = possible_values(Status::value_variants());
|
||||
let shells = possible_values(Shell::value_variants());
|
||||
let skills = SKILLS
|
||||
.iter()
|
||||
.map(|skill| skill.name)
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ");
|
||||
|
||||
format!(
|
||||
r#"
|
||||
# ---------------------------------------------------------------------------
|
||||
# Dynamic values, appended by `worklane completions fish`. Fish accumulates
|
||||
# completions, so these add to the generated rules above.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Almost every argument worklane takes names something on the board rather than
|
||||
# something on disk, so stop fish falling back to the directory listing. Without this,
|
||||
# `worklane show 1b78a24 <TAB>` offers Cargo.toml and src/.
|
||||
complete -c worklane -f
|
||||
|
||||
# The exception, and the reason the line above is not the whole story: `tui` takes
|
||||
# project paths, as many as you like. Directories only, since each is resolved to the
|
||||
# first `.worklane` at or above it.
|
||||
complete -c worklane -n '__fish_seen_subcommand_from tui' \
|
||||
-a '(__fish_complete_directories)' -d project
|
||||
|
||||
# Position is counted rather than inferred from what has been typed: matching against
|
||||
# the ticket list would run worklane again inside the condition, and would also keep
|
||||
# offering tickets after one had been chosen.
|
||||
#
|
||||
# The subcommand is the second token, so its first argument is being typed once two
|
||||
# tokens are there. `$tokens[2]` rather than `__fish_seen_subcommand_from`, because
|
||||
# `campaign ls` and `campaign show` are also an `ls` and a `show` that fish has seen,
|
||||
# and their arguments are not what these complete.
|
||||
function __worklane_first_arg_of
|
||||
set -l tokens (commandline -opc)
|
||||
test (count $tokens) -eq 2; and contains -- $tokens[2] $argv
|
||||
end
|
||||
|
||||
function __worklane_second_arg_of
|
||||
set -l tokens (commandline -opc)
|
||||
test (count $tokens) -eq 3; and contains -- $tokens[2] $argv
|
||||
end
|
||||
|
||||
# No `-d`: `ls --ids` prints the id and the title separated by a tab, which is fish's
|
||||
# own form for a candidate and its description, so every ticket carries its own.
|
||||
complete -c worklane \
|
||||
-n '__worklane_first_arg_of {ticket_commands}; or __worklane_second_arg_of {ticket_second_commands}' \
|
||||
-a '(worklane ls --ids)'
|
||||
|
||||
# `relate` takes its targets as option values, so they are completed by flag rather
|
||||
# than by position.
|
||||
complete -c worklane {ticket_flags} -x -a '(worklane ls --ids)'
|
||||
|
||||
# clap emits the four for `mv --status`, which is an option, but the fish generator
|
||||
# emits nothing for the possible values of a positional. So the one place a status is
|
||||
# positional needs them listed, and the same goes for the shell below.
|
||||
complete -c worklane -n '__worklane_first_arg_of ls' -a '{statuses}' -d status
|
||||
complete -c worklane -n '__worklane_first_arg_of completions' -a '{shells}' -d shell
|
||||
|
||||
# Shipped with the binary, so this list comes from `install::SKILLS` and cannot fall
|
||||
# behind it.
|
||||
complete -c worklane -n '__worklane_first_arg_of install-skill' -a '{skills}' -d skill
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
/// The names a `ValueEnum` accepts, for a fish `-a` list.
|
||||
///
|
||||
/// Read off the enum rather than written out, so a status or a shell added to either one
|
||||
/// is offered without anybody remembering this file. A variant marked hidden is left out,
|
||||
/// which is what `to_possible_value` returning `None` means.
|
||||
fn possible_values<T: ValueEnum>(variants: &[T]) -> String {
|
||||
variants
|
||||
.iter()
|
||||
.filter_map(|variant| variant.to_possible_value())
|
||||
.map(|value| value.get_name().to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Built, not just derived: an index is assigned when the command is built, and the
|
||||
/// positionals of an unbuilt one all report `None`.
|
||||
fn command() -> clap::Command {
|
||||
let mut cli = crate::command::Cli::command();
|
||||
cli.build();
|
||||
cli
|
||||
}
|
||||
|
||||
/// Every subcommand that takes a ticket must be listed, at the position it takes it,
|
||||
/// or it silently loses completion.
|
||||
///
|
||||
/// The nested subcommands are not walked. `campaign` is the only one, none of its
|
||||
/// three takes a ticket, and the token counting above could not tell them apart if
|
||||
/// one did. A ticket argument added under `campaign` needs the fish block reworked,
|
||||
/// not another name in a list.
|
||||
#[test]
|
||||
fn no_ticket_taking_subcommand_is_missing() {
|
||||
for subcommand in command().get_subcommands() {
|
||||
let name = subcommand.get_name();
|
||||
for positional in subcommand.get_positionals() {
|
||||
// `show` calls it `id`; everything else calls it `ticket`.
|
||||
if !matches!(positional.get_id().as_str(), "ticket" | "id") {
|
||||
continue;
|
||||
}
|
||||
match positional.get_index() {
|
||||
Some(1) => assert!(
|
||||
TICKET_COMMANDS.contains(&name),
|
||||
"`worklane {name}` takes a ticket first but is not in TICKET_COMMANDS"
|
||||
),
|
||||
Some(2) => assert!(
|
||||
TICKET_SECOND_COMMANDS.contains(&name),
|
||||
"`worklane {name}` takes a ticket second but is not in \
|
||||
TICKET_SECOND_COMMANDS"
|
||||
),
|
||||
index => panic!("`worklane {name}` takes a ticket at position {index:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_listed_command_is_a_real_subcommand() {
|
||||
let cli = command();
|
||||
let known: Vec<&str> = cli.get_subcommands().map(|c| c.get_name()).collect();
|
||||
for name in TICKET_COMMANDS.iter().chain(TICKET_SECOND_COMMANDS.iter()) {
|
||||
assert!(known.contains(name), "no such subcommand: {name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The flags completed as tickets have to be `relate`'s actual flags, or the rule
|
||||
/// completes an option nothing accepts.
|
||||
#[test]
|
||||
fn every_ticket_flag_is_a_real_option() {
|
||||
let relate = command()
|
||||
.find_subcommand("relate")
|
||||
.expect("relate exists")
|
||||
.clone();
|
||||
let known: Vec<String> = relate
|
||||
.get_arguments()
|
||||
.filter_map(|arg| arg.get_long().map(str::to_string))
|
||||
.collect();
|
||||
for flag in TICKET_FLAGS {
|
||||
assert!(
|
||||
known.contains(&flag.to_string()),
|
||||
"`relate` has no --{flag}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_fish_script_asks_worklane_for_its_tickets() {
|
||||
let script = fish_dynamic();
|
||||
assert!(script.contains("worklane ls --ids"));
|
||||
// Both positions, in one rule.
|
||||
assert!(script.contains("__worklane_first_arg_of show"));
|
||||
assert!(script.contains("__worklane_second_arg_of chown assign"));
|
||||
// Nothing here takes a file, bar the one that does.
|
||||
assert!(script.contains("complete -c worklane -f\n"));
|
||||
assert!(script.contains("__fish_complete_directories"));
|
||||
// Generated from `install::SKILLS`, so every shipped skill is in it.
|
||||
assert!(script.contains("worklane-review"));
|
||||
}
|
||||
|
||||
/// The one status positional and the one shell positional, which clap does not emit
|
||||
/// possible values for. Read off the enums, so a fifth status would appear here on
|
||||
/// its own.
|
||||
#[test]
|
||||
fn the_fish_script_lists_the_statuses_and_the_shells() {
|
||||
let script = fish_dynamic();
|
||||
for status in Status::ALL {
|
||||
assert!(
|
||||
script.contains(status.as_str()),
|
||||
"the ls positional is never offered {}",
|
||||
status.as_str()
|
||||
);
|
||||
}
|
||||
assert!(script.contains("-a 'backlog committed reviewing done' -d status"));
|
||||
for shell in ["fish", "bash", "zsh", "elvish", "powershell"] {
|
||||
assert!(script.contains(shell), "the shell positional is never offered {shell}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The four for `mv --status` are clap's, which is half of why `Status` is a
|
||||
/// `ValueEnum`. If clap ever stops emitting them, the fish half has to carry them
|
||||
/// too, and this is what says so.
|
||||
#[test]
|
||||
fn clap_emits_the_statuses_for_the_status_flag() {
|
||||
let mut out = Vec::new();
|
||||
generate(Shell::Fish, &mut out).expect("generates");
|
||||
let script = String::from_utf8(out).expect("utf8");
|
||||
let flag = script
|
||||
.lines()
|
||||
.find(|line| line.contains("using_subcommand mv") && line.contains("-l status"))
|
||||
.expect("mv --status has a rule of its own");
|
||||
assert!(flag.contains("backlog"), "{flag}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generating_fish_produces_both_halves() {
|
||||
let mut out = Vec::new();
|
||||
generate(Shell::Fish, &mut out).expect("generates");
|
||||
let script = String::from_utf8(out).expect("utf8");
|
||||
// clap's half.
|
||||
assert!(script.contains("complete -c worklane"));
|
||||
assert!(script.contains("install-skill"));
|
||||
// Ours.
|
||||
assert!(script.contains("__worklane_first_arg_of"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn other_shells_get_only_the_generated_half() {
|
||||
for shell in [Shell::Bash, Shell::Zsh] {
|
||||
let mut out = Vec::new();
|
||||
generate(shell, &mut out).expect("generates");
|
||||
let script = String::from_utf8(out).expect("utf8");
|
||||
assert!(
|
||||
!script.contains("__worklane_first_arg_of"),
|
||||
"fish-only helpers leaked into {shell}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1059
-128
File diff suppressed because it is too large
Load Diff
+424
@@ -0,0 +1,424 @@
|
||||
//! Shipping the agent assets with the binary.
|
||||
//!
|
||||
//! The skill documents live in `assets/` in this repo and are embedded with
|
||||
//! `include_str!` rather than copied by an install script, because `cargo install`
|
||||
//! places binaries and nothing else. Embedding means a document can never be a
|
||||
//! different version from the binary it describes, and there is no second file to
|
||||
//! lose track of.
|
||||
//!
|
||||
//! `SKILLS` is every skill the binary carries, and `install-skill` writes all of them.
|
||||
//! One document teaches the CLI and the others teach a job done with it; a person who
|
||||
//! has learned the invocation should not have to learn a new name for each document
|
||||
//! added later, or the new one silently never arrives.
|
||||
//!
|
||||
//! The machinery is written once for both kinds of asset this repo will ship. The tool
|
||||
//! file for opencode is executable code needing Bun, so it gets its own command and its
|
||||
//! own root, but the compare-and-refuse logic is the same and lives here.
|
||||
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
|
||||
/// One thing the binary carries and can write into a user's agent configuration.
|
||||
pub struct Asset {
|
||||
/// How it is addressed on the command line. For a skill this is also its directory
|
||||
/// and its frontmatter `name:`, which both agents require to agree.
|
||||
pub name: &'static str,
|
||||
/// What it is called in messages, e.g. `skill`.
|
||||
pub what: &'static str,
|
||||
/// Where it goes under its root, e.g. `worklane/SKILL.md`.
|
||||
pub relative: &'static str,
|
||||
pub content: &'static str,
|
||||
}
|
||||
|
||||
/// The skill that teaches the CLI, as of the commit this binary was built from.
|
||||
pub const SKILL: Asset = Asset {
|
||||
name: "worklane",
|
||||
what: "skill",
|
||||
relative: "worklane/SKILL.md",
|
||||
content: include_str!("../assets/SKILL.md"),
|
||||
};
|
||||
|
||||
/// The skill that reviews a finished ticket against the code that claims to close it.
|
||||
///
|
||||
/// A document of its own rather than a section of `SKILL`, because it is loaded for a
|
||||
/// different job: the CLI skill is wanted for anything touching a ticket, and this is
|
||||
/// wanted only when a review is asked for. One document holding both would be loaded
|
||||
/// constantly to say nothing, and the frontmatter description, which is the whole of
|
||||
/// what decides the loading, cannot describe two jobs without fitting neither.
|
||||
pub const REVIEW_SKILL: Asset = Asset {
|
||||
name: "worklane-review",
|
||||
what: "skill",
|
||||
relative: "worklane-review/SKILL.md",
|
||||
content: include_str!("../assets/REVIEW.md"),
|
||||
};
|
||||
|
||||
/// The skill that grooms the board as a whole rather than a ticket at a time.
|
||||
///
|
||||
/// Its own document for the reason `REVIEW_SKILL` is: it is wanted for questions about
|
||||
/// the backlog as a body of work, and loading it for every ticket touched would be a
|
||||
/// description that fits nothing. It is also the document where the destructive edits
|
||||
/// live, since every job in it writes to many tickets at once.
|
||||
pub const PLAN_SKILL: Asset = Asset {
|
||||
name: "worklane-plan",
|
||||
what: "skill",
|
||||
relative: "worklane-plan/SKILL.md",
|
||||
content: include_str!("../assets/PLAN.md"),
|
||||
};
|
||||
|
||||
/// Every skill this binary carries, in the order they install.
|
||||
///
|
||||
/// A `static` rather than a `const` so the slice borrowed from it outlives the
|
||||
/// statement that took it: a `const` is inlined at each use and the borrow dies there.
|
||||
pub static SKILLS: [Asset; 3] = [SKILL, REVIEW_SKILL, PLAN_SKILL];
|
||||
|
||||
/// The skill a name on the command line asks for.
|
||||
pub fn skill_named(name: &str) -> Result<&'static Asset> {
|
||||
SKILLS.iter().find(|asset| asset.name == name).ok_or_else(|| {
|
||||
anyhow!("no skill named {name:?}. This binary ships {}", skill_names())
|
||||
})
|
||||
}
|
||||
|
||||
/// The names, for the errors that have to say what there is to choose from.
|
||||
pub fn skill_names() -> String {
|
||||
SKILLS
|
||||
.iter()
|
||||
.map(|asset| asset.name)
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
}
|
||||
|
||||
/// Where a skill has to sit to be found, for both agents worklane is used from.
|
||||
///
|
||||
/// One path serves both. Claude Code reads `~/.claude/skills/<name>/SKILL.md`, and
|
||||
/// opencode loads that same directory as an external skill source, alongside its own
|
||||
/// `~/.config/opencode/skill/`. Checked against opencode 1.15.10, whose built-in
|
||||
/// `customize-opencode` skill documents it and whose `opencode debug skill` lists the
|
||||
/// documents found there. Writing both paths would be two copies of one document, free
|
||||
/// to drift apart, for no gain.
|
||||
pub fn skills_root() -> Result<PathBuf> {
|
||||
let home = std::env::var_os("HOME").ok_or_else(|| {
|
||||
anyhow!("cannot tell where your skills live because HOME is not set in the environment")
|
||||
})?;
|
||||
|
||||
Ok(Path::new(&home).join(".claude/skills"))
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Outcome {
|
||||
Written(PathBuf),
|
||||
/// Already byte-identical, so writing it again would be a no-op.
|
||||
Unchanged(PathBuf),
|
||||
/// Present but different, and no `--force`. Refused rather than overwritten: it
|
||||
/// may have been edited on purpose, and silently discarding that is worse than
|
||||
/// stopping.
|
||||
Refused(PathBuf),
|
||||
}
|
||||
|
||||
impl Asset {
|
||||
pub fn path(&self, root: &Path) -> PathBuf {
|
||||
root.join(self.relative)
|
||||
}
|
||||
|
||||
/// Write the asset under `root`, unless what is there is the same or was changed.
|
||||
///
|
||||
/// The root is passed in rather than looked up, so a test can install into a
|
||||
/// temporary directory instead of the home of whoever runs the suite.
|
||||
pub fn install(&self, root: &Path, force: bool) -> io::Result<Outcome> {
|
||||
let path = self.path(root);
|
||||
|
||||
// A read error is not treated as "absent": the write below reports it, with
|
||||
// the real reason, rather than this guessing that the file is missing.
|
||||
match std::fs::read_to_string(&path) {
|
||||
Ok(existing) if existing == self.content => return Ok(Outcome::Unchanged(path)),
|
||||
Ok(_) if !force => return Ok(Outcome::Refused(path)),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
std::fs::write(&path, self.content)?;
|
||||
|
||||
Ok(Outcome::Written(path))
|
||||
}
|
||||
}
|
||||
|
||||
/// The `name:` and `description:` from the YAML frontmatter.
|
||||
///
|
||||
/// Used by the tests that guard the shipping mechanism, which is the only thing that
|
||||
/// needs it: both agents decide whether to load a document from these two fields, and
|
||||
/// a document missing them is ignored in silence.
|
||||
#[cfg_attr(not(test), allow(dead_code))]
|
||||
fn frontmatter_field(text: &str, key: &str) -> Option<String> {
|
||||
let body = text.strip_prefix("---\n")?;
|
||||
let end = body.find("\n---")?;
|
||||
body[..end]
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix(&format!("{key}:")))
|
||||
.map(|value| value.trim().to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn root() -> tempfile::TempDir {
|
||||
tempfile::tempdir().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_skill_installs_into_a_directory_that_does_not_exist_yet() {
|
||||
let root = root();
|
||||
let path = SKILL.path(root.path());
|
||||
|
||||
assert_eq!(
|
||||
SKILL.install(root.path(), false).unwrap(),
|
||||
Outcome::Written(path.clone())
|
||||
);
|
||||
assert_eq!(std::fs::read_to_string(&path).unwrap(), SKILL.content);
|
||||
}
|
||||
|
||||
/// Installing twice is a no-op rather than a rewrite, so the mtime of an
|
||||
/// up-to-date copy does not move.
|
||||
#[test]
|
||||
fn a_second_install_reports_the_copy_unchanged() {
|
||||
let root = root();
|
||||
SKILL.install(root.path(), false).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
SKILL.install(root.path(), false).unwrap(),
|
||||
Outcome::Unchanged(SKILL.path(root.path()))
|
||||
);
|
||||
}
|
||||
|
||||
/// The case worth being careful about: an edited copy is someone's work.
|
||||
#[test]
|
||||
fn a_modified_copy_is_refused_and_left_alone() {
|
||||
let root = root();
|
||||
let path = SKILL.path(root.path());
|
||||
SKILL.install(root.path(), false).unwrap();
|
||||
std::fs::write(&path, "hand written\n").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
SKILL.install(root.path(), false).unwrap(),
|
||||
Outcome::Refused(path.clone())
|
||||
);
|
||||
assert_eq!(std::fs::read_to_string(&path).unwrap(), "hand written\n");
|
||||
|
||||
assert_eq!(
|
||||
SKILL.install(root.path(), true).unwrap(),
|
||||
Outcome::Written(path.clone())
|
||||
);
|
||||
assert_eq!(std::fs::read_to_string(&path).unwrap(), SKILL.content);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_skill_lands_where_both_agents_look_for_it() {
|
||||
let root = skills_root().unwrap();
|
||||
assert!(root.ends_with(".claude/skills"), "{}", root.display());
|
||||
|
||||
for asset in &SKILLS {
|
||||
let path = asset.path(&root);
|
||||
assert!(
|
||||
path.ends_with(format!(".claude/skills/{}/SKILL.md", asset.name)),
|
||||
"{}",
|
||||
path.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Two documents that install to one path means the second silently replaces the
|
||||
/// first, and only whichever is listed last is ever read. A copy-pasted `relative`
|
||||
/// is exactly how that happens.
|
||||
#[test]
|
||||
fn no_two_shipped_skills_share_a_name_or_a_path() {
|
||||
for (index, asset) in SKILLS.iter().enumerate() {
|
||||
for other in &SKILLS[index + 1..] {
|
||||
assert_ne!(asset.name, other.name);
|
||||
assert_ne!(asset.relative, other.relative);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_embedded_skill_has_usable_frontmatter() {
|
||||
// Guards the whole shipping mechanism: without frontmatter, or under a name
|
||||
// that does not match its directory, both agents ignore the document and
|
||||
// nothing else would notice.
|
||||
for asset in &SKILLS {
|
||||
assert_eq!(
|
||||
frontmatter_field(asset.content, "name").as_deref(),
|
||||
Some(asset.name),
|
||||
"the frontmatter name has to match the directory it installs into"
|
||||
);
|
||||
|
||||
let description = frontmatter_field(asset.content, "description")
|
||||
.unwrap_or_else(|| panic!("{} ships without a description to trigger on", asset.name));
|
||||
assert!(
|
||||
description.len() > 80,
|
||||
"{}: the description is what decides whether the skill loads at all",
|
||||
asset.name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Every code span and fenced-block line, which is where commands live.
|
||||
///
|
||||
/// Prose has to be excluded: the document opens by calling worklane a kanban
|
||||
/// board, and treating that sentence as a command makes the check useless.
|
||||
fn code_snippets(text: &str) -> Vec<String> {
|
||||
let mut snippets = Vec::new();
|
||||
let mut fenced = false;
|
||||
for line in text.lines() {
|
||||
if line.trim_start().starts_with("```") {
|
||||
fenced = !fenced;
|
||||
continue;
|
||||
}
|
||||
if fenced {
|
||||
snippets.push(line.to_string());
|
||||
continue;
|
||||
}
|
||||
// Inline spans: the odd-numbered pieces between backticks.
|
||||
for (index, piece) in line.split('`').enumerate() {
|
||||
if index % 2 == 1 {
|
||||
snippets.push(piece.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
snippets
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_embedded_skill_names_a_command_that_does_not_exist() {
|
||||
// Taken from clap rather than written out here. A hand-maintained list is the
|
||||
// very drift this test exists to catch.
|
||||
use clap::CommandFactory;
|
||||
let mut known: Vec<String> = crate::Cli::command()
|
||||
.get_subcommands()
|
||||
.map(|c| c.get_name().to_string())
|
||||
.collect();
|
||||
known.push("--help".to_string());
|
||||
known.push("--version".to_string());
|
||||
|
||||
let mut total = 0;
|
||||
for asset in &SKILLS {
|
||||
let mut checked = 0;
|
||||
for snippet in code_snippets(asset.content) {
|
||||
let mut words = snippet.split_whitespace();
|
||||
// Only a snippet that *starts* with worklane is a command being shown.
|
||||
if words.next() != Some("worklane") {
|
||||
continue;
|
||||
}
|
||||
let Some(candidate) = words.next() else { continue };
|
||||
// A flag before the subcommand, as in the `mv -- -leading-title` example.
|
||||
if candidate.starts_with("--") && !known.iter().any(|k| k == candidate) {
|
||||
continue;
|
||||
}
|
||||
checked += 1;
|
||||
assert!(
|
||||
known.iter().any(|k| k == candidate),
|
||||
"{} shows `worklane {candidate}`, which is not a subcommand",
|
||||
asset.name
|
||||
);
|
||||
}
|
||||
// A skill that shows no command at all is either not about worklane or has
|
||||
// had its examples emptied out, and either way the check above passed on
|
||||
// nothing.
|
||||
assert!(checked > 0, "{} shows no worklane command at all", asset.name);
|
||||
total += checked;
|
||||
}
|
||||
assert!(total > 8, "expected the skills to show commands, checked only {total}");
|
||||
}
|
||||
|
||||
/// Subcommands the skill has no business teaching: the board is interactive and
|
||||
/// belongs to a person, `install-skill` is how the document arrived, and `help`
|
||||
/// is clap's own.
|
||||
const NOT_FOR_AGENTS: [&str; 3] = ["tui", "install-skill", "help"];
|
||||
|
||||
/// The converse, and the one that goes stale on its own: a *new* subcommand absent
|
||||
/// from the skill is invisible to an agent, and nothing else would notice.
|
||||
///
|
||||
/// `SKILL` alone, deliberately. It is the document that owns the CLI surface, and
|
||||
/// the others teach one job with the handful of commands that job uses. Requiring
|
||||
/// every subcommand of each of them would fill a review document with campaigns
|
||||
/// and `init` to satisfy a test.
|
||||
#[test]
|
||||
fn every_agent_facing_subcommand_is_documented() {
|
||||
use clap::CommandFactory;
|
||||
for command in crate::Cli::command().get_subcommands() {
|
||||
let name = command.get_name();
|
||||
if NOT_FOR_AGENTS.contains(&name) {
|
||||
continue;
|
||||
}
|
||||
assert!(
|
||||
SKILL.content.contains(&format!("worklane {name}")),
|
||||
"the skill never mentions `worklane {name}`, so an agent will not know it exists"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The facts an agent cannot infer from the help output and would get wrong.
|
||||
#[test]
|
||||
fn the_embedded_skill_documents_what_the_help_does_not() {
|
||||
for required in [
|
||||
"committed",
|
||||
"as you work it",
|
||||
"UUID prefix",
|
||||
"leading hyphen",
|
||||
"Search the backlog before filing",
|
||||
] {
|
||||
assert!(
|
||||
SKILL.content.contains(required),
|
||||
"the skill no longer mentions {required:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The rules that keep a grooming sweep from being a silent rewrite of the board.
|
||||
///
|
||||
/// Every one of these is a line an edit could drop while leaving a document that
|
||||
/// still reads like a plan: `set --tags` replacing the whole field is how thirty
|
||||
/// tickets quietly lose their tags, and propose-then-apply is the only thing
|
||||
/// standing between a wrong judgement and thirty wrong tickets.
|
||||
#[test]
|
||||
fn the_plan_skill_keeps_the_rules_that_bound_a_sweep() {
|
||||
for required in [
|
||||
"Propose the whole set of edits",
|
||||
"replaces the whole\nfield", // `set --tags` is the destructive one
|
||||
"cannot be cleared", // and a due date cannot be taken back
|
||||
"blocked by", // ordering constrains any dating plan
|
||||
"worklane campaign ls",
|
||||
"does not touch",
|
||||
] {
|
||||
assert!(
|
||||
PLAN_SKILL.content.contains(required),
|
||||
"the plan skill no longer says {required:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The decisions that make the review document a review rather than a rewrite.
|
||||
///
|
||||
/// Each of these is a rule an edit would drop without breaking anything else: a
|
||||
/// reviewer that ticks criteria or moves the ticket still runs, and produces a
|
||||
/// board where nothing records that anyone disagreed.
|
||||
#[test]
|
||||
fn the_review_skill_keeps_the_decisions_that_define_it() {
|
||||
for required in [
|
||||
"worklane show", // the ticket is read before the code
|
||||
"nothing names the ticket", // and the no-work-found case is answered
|
||||
"Never tick a criterion",
|
||||
"Do not move the ticket",
|
||||
"worklane uncheck",
|
||||
"worklane append",
|
||||
"cannot tell",
|
||||
] {
|
||||
assert!(
|
||||
REVIEW_SKILL.content.contains(required),
|
||||
"the review skill no longer says {required:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+206
-27
@@ -1,54 +1,233 @@
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
|
||||
mod campaign;
|
||||
mod clipboard;
|
||||
mod command;
|
||||
mod completions;
|
||||
mod handlers;
|
||||
mod install;
|
||||
mod tui;
|
||||
mod util;
|
||||
|
||||
use command::*;
|
||||
use handlers::*;
|
||||
use util::*;
|
||||
|
||||
/// Die quietly when stdout is closed early, the way every other Unix tool does.
|
||||
///
|
||||
/// Rust sets `SIGPIPE` to `SIG_IGN` at startup, which turns a closed pipe into an
|
||||
/// io error that `println!` panics on. So `worklane ls | head -3` printed a panic
|
||||
/// and a backtrace instead of three lines, which is both alarming and easy to
|
||||
/// mistake for a real fault. Restoring the default handler makes `| head` behave.
|
||||
///
|
||||
/// The cost is that a truncated pipe now kills the process with signal 13 rather
|
||||
/// than returning a code, so `pipefail` sees 141 instead of 101. That is what
|
||||
/// `head` and `sort` do, and it is recorded in the README.
|
||||
fn quiet_broken_pipe() {
|
||||
// SAFETY: setting a signal disposition to the default is always valid, and
|
||||
// this runs before any thread is spawned.
|
||||
unsafe {
|
||||
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// Before any output, so no write can beat it to a closed pipe.
|
||||
quiet_broken_pipe();
|
||||
|
||||
let cli = Cli::parse();
|
||||
|
||||
let start = std::env::current_dir()?;
|
||||
|
||||
match cli.command {
|
||||
Command::Init => cmd_init(&start),
|
||||
Command::Add {
|
||||
title,
|
||||
description,
|
||||
acceptance,
|
||||
plan,
|
||||
tags,
|
||||
due,
|
||||
owner,
|
||||
priority,
|
||||
} => cmd_add(
|
||||
&title,
|
||||
&description,
|
||||
&acceptance,
|
||||
&plan,
|
||||
&tags,
|
||||
&due,
|
||||
&owner,
|
||||
priority,
|
||||
&start,
|
||||
),
|
||||
Command::Ls { status, priority } => {
|
||||
// No subcommand opens the board, the way a bare `frig` does, and with no path
|
||||
// it opens the board above the working directory.
|
||||
None => run_tui(&[], &start),
|
||||
Some(Command::Tui { paths }) => run_tui(&paths, &start),
|
||||
Some(Command::Init) => cmd_init(&start),
|
||||
Some(Command::Add(args)) => cmd_add(&args, &start),
|
||||
Some(Command::Ls(args)) => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_ls(&status, priority, &worklane_dir)
|
||||
cmd_ls(&args, &worklane_dir)
|
||||
}
|
||||
Command::Show { id } => {
|
||||
Some(Command::Show { id }) => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_show(&id, &worklane_dir)
|
||||
}
|
||||
Command::Mv {
|
||||
Some(Command::Mv {
|
||||
ticket,
|
||||
status,
|
||||
force,
|
||||
} => cmd_mv(&ticket, &status, force, &start),
|
||||
Command::Comment { ticket, body, owner } => cmd_comment(&ticket, &body, &owner, &start),
|
||||
}) => cmd_mv(&ticket, status, force, &start),
|
||||
Some(Command::Set(args)) => cmd_set(&args, &start),
|
||||
Some(Command::Append(args)) => cmd_append(&args, &start),
|
||||
Some(Command::Relate(args)) => cmd_relate(&args, &start),
|
||||
Some(Command::Chown { user, ticket }) => cmd_chown(&user, &ticket, &start),
|
||||
Some(Command::Check(args)) => cmd_check(&args, true, &start),
|
||||
Some(Command::Uncheck(args)) => cmd_check(&args, false, &start),
|
||||
Some(Command::Comment {
|
||||
ticket,
|
||||
body,
|
||||
owner,
|
||||
}) => cmd_comment(&ticket, &body, &owner, &start),
|
||||
Some(Command::Campaign { command }) => match command {
|
||||
CampaignCommand::Add(args) => cmd_campaign_add(&args, &start),
|
||||
CampaignCommand::Ls => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_campaign_ls(&worklane_dir)
|
||||
}
|
||||
CampaignCommand::Show { campaign } => {
|
||||
let worklane_dir = find_worklane_dir(&start)?;
|
||||
cmd_campaign_show(&campaign, &worklane_dir)
|
||||
}
|
||||
},
|
||||
Some(Command::Assign { campaign, ticket }) => cmd_assign(&campaign, &ticket, &start),
|
||||
// No board either, for the reason `install-skill` has none: a completion script
|
||||
// is generated from the clap definition and is the same wherever it is run.
|
||||
Some(Command::Completions { shell }) => {
|
||||
completions::generate(shell, &mut std::io::stdout()).map_err(Into::into)
|
||||
}
|
||||
// No board is looked for: the point of the skill is to teach an agent worklane
|
||||
// before there is a `.worklane` anywhere.
|
||||
Some(Command::InstallSkill { skill, force, print }) => {
|
||||
cmd_install_skill(skill.as_deref(), force, print)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------- tui --
|
||||
|
||||
/// Restore the terminal whatever happens.
|
||||
///
|
||||
/// A panic inside the draw loop with raw mode still on leaves the shell unusable and
|
||||
/// the backtrace unreadable, so the hook runs before the default one.
|
||||
fn install_panic_hook() {
|
||||
let previous = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |info| {
|
||||
let _ = restore_terminal();
|
||||
previous(info);
|
||||
}));
|
||||
}
|
||||
|
||||
fn restore_terminal() -> std::io::Result<()> {
|
||||
crossterm::terminal::disable_raw_mode()?;
|
||||
crossterm::execute!(
|
||||
std::io::stdout(),
|
||||
crossterm::terminal::LeaveAlternateScreen
|
||||
)
|
||||
}
|
||||
|
||||
fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()> {
|
||||
use crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers};
|
||||
use std::io::IsTerminal;
|
||||
|
||||
// The boards are looked for before the terminal is, so running this outside a
|
||||
// worklane directory gives the same message every other command gives rather than
|
||||
// a complaint about the terminal.
|
||||
let projects = tui::projects(paths, start)?;
|
||||
|
||||
// Without this, entering raw mode on a pipe fails with a bare "No such device or
|
||||
// address (os error 6)", which says nothing about the actual mistake. A bare
|
||||
// `worklane` is how the board is opened, so a script that reaches it by accident
|
||||
// has to be pointed at a subcommand.
|
||||
if !std::io::stdin().is_terminal() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"`worklane` with no subcommand opens the board, which needs a terminal.\n\
|
||||
For scripted use try `worklane ls` or `worklane show`; `worklane --help` \
|
||||
lists everything."
|
||||
));
|
||||
}
|
||||
|
||||
let mut board = tui::Board::new(projects)?;
|
||||
|
||||
install_panic_hook();
|
||||
crossterm::terminal::enable_raw_mode()?;
|
||||
crossterm::execute!(std::io::stdout(), crossterm::terminal::EnterAlternateScreen)?;
|
||||
let mut terminal =
|
||||
ratatui::Terminal::new(ratatui::backend::CrosstermBackend::new(std::io::stdout()))?;
|
||||
|
||||
let result = (|| -> Result<()> {
|
||||
while !board.should_quit {
|
||||
board.tick()?;
|
||||
terminal.draw(|frame| tui::draw(frame, &board))?;
|
||||
|
||||
// Taken after the draw, so a scroll measures the overlay that is on screen.
|
||||
let screen = terminal.size()?;
|
||||
|
||||
// Bounded, so the tick still runs when nobody is typing.
|
||||
if !event::poll(tui::POLL)? {
|
||||
continue;
|
||||
}
|
||||
let Event::Key(key) = event::read()? else {
|
||||
continue;
|
||||
};
|
||||
if key.kind != KeyEventKind::Press {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Every keypress takes away what the last one said, so a notice never
|
||||
// outlives the moment it belongs to. Ahead of the prompt as well as the
|
||||
// arms: a key typed into a query is still a key. The rule is
|
||||
// `Board::clear_notice`, where a test can reach it, and the arm below that
|
||||
// sets one runs after this.
|
||||
board.clear_notice();
|
||||
|
||||
// Ahead of the arms, because a prompt has to swallow every key it is
|
||||
// given: typing `d` into a query must not toggle the done column and `q`
|
||||
// must not quit. It reports what it took, so the arms below stay a plain
|
||||
// match on the keys it did not, and it takes nothing when no prompt is open.
|
||||
// The rule is `Board::search_key`, where a test can reach it.
|
||||
if board.search_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(),
|
||||
// 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) => {
|
||||
board.should_quit = true
|
||||
}
|
||||
KeyCode::Enter | KeyCode::Char(' ') => board.toggle_detail(),
|
||||
KeyCode::Left | KeyCode::Char('h') => board.select_column(-1, screen),
|
||||
KeyCode::Right | KeyCode::Char('l') => board.select_column(1, screen),
|
||||
// Up and down stay on the selection, open detail view or not, so a
|
||||
// column can be read through without closing the modal. Scrolling the
|
||||
// open ticket is a page at a time.
|
||||
KeyCode::Up | KeyCode::Char('k') => board.select_card(-1, screen),
|
||||
KeyCode::Down | KeyCode::Char('j') => board.select_card(1, screen),
|
||||
KeyCode::PageUp => board.scroll_detail(-1, screen),
|
||||
KeyCode::PageDown => board.scroll_detail(1, screen),
|
||||
// Tabs cycle rather than clamp, the way tabs everywhere do, and are
|
||||
// a no-op with a single board. Free of every other binding: the
|
||||
// columns took hjkl and the arrows.
|
||||
KeyCode::Tab => board.select_tab(1, screen),
|
||||
KeyCode::BackTab => board.select_tab(-1, screen),
|
||||
// Free of the other bindings, and the footer names it in both states.
|
||||
KeyCode::Char('d') => board.toggle_done(screen),
|
||||
// An ordinary single-shot action like the rest: it opens the prompt, and
|
||||
// from the next keypress on `search_key` above has the keyboard. A `/`
|
||||
// typed into an open prompt is taken there as a character, so this arm
|
||||
// is only ever the way in.
|
||||
KeyCode::Char('/') => board.open_search(),
|
||||
// `y` as in yank, for the readers this board is for, and the only letter
|
||||
// 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),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})();
|
||||
|
||||
// Before the error surfaces, so a failure does not leave the shell in raw mode.
|
||||
restore_terminal()?;
|
||||
result
|
||||
}
|
||||
|
||||
+4788
File diff suppressed because it is too large
Load Diff
+2993
-175
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,173 @@
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
/// What a truncated pipe costs: the process dies by signal rather than returning a
|
||||
/// code, so a shell reports 128 + 13. Asserted here so the README and the code stay
|
||||
/// honest about what `pipefail` sees.
|
||||
const SIGPIPE: i32 = 13;
|
||||
|
||||
/// A pipe holds 64 KiB on Linux before a write blocks. Below that the whole listing
|
||||
/// lands in the buffer, the writer never notices the reader is gone, and a test
|
||||
/// proves nothing. Every ticket here is one `ls` row of roughly a hundred bytes.
|
||||
const TICKETS: usize = 1200;
|
||||
|
||||
fn setup_crowded_board(temp: &TempDir) -> std::path::PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
let backlog = worklane.path().join("backlog");
|
||||
for i in 0..TICKETS {
|
||||
let id = format!("{:08x}-0000-4000-8000-000000000000", i);
|
||||
let title = format!("A ticket with a title long enough to fill a row {}", i);
|
||||
fs::write(
|
||||
backlog.join(format!("{}_ticket-{}.md", id, i)),
|
||||
format!(
|
||||
"# {}\n\n## Metadata\n\n\
|
||||
- **ID**: {}\n\
|
||||
- **Owner**: someone with a name\n\
|
||||
- **Status**: backlog\n",
|
||||
title, id
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
temp.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn panic_text(stderr: &str) -> bool {
|
||||
stderr.contains("panicked")
|
||||
|| stderr.contains("failed printing to stdout")
|
||||
|| stderr.contains("Broken pipe")
|
||||
}
|
||||
|
||||
/// The reader closed before the writer finished: dropping the read end here is the
|
||||
/// same thing `head` does when it has seen enough, without the timing luck.
|
||||
fn run_with_stdout_dropped(dir: &std::path::Path, args: &[&str]) -> std::process::Output {
|
||||
let mut child = Command::new(BIN_NAME)
|
||||
.args(args)
|
||||
.current_dir(dir)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
drop(child.stdout.take().unwrap());
|
||||
child.wait_with_output().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ls_says_nothing_when_the_reader_goes_away() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let dir = setup_crowded_board(&temp);
|
||||
|
||||
let output = run_with_stdout_dropped(&dir, &["ls", "backlog"]);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
assert!(!panic_text(&stderr), "stderr was {stderr:?}");
|
||||
assert_ne!(output.status.code(), Some(101), "panicked instead of dying");
|
||||
assert_eq!(
|
||||
output.status.signal(),
|
||||
Some(SIGPIPE),
|
||||
"expected death by SIGPIPE, got {:?}",
|
||||
output.status
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_says_nothing_when_the_reader_goes_away() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let dir = setup_crowded_board(&temp);
|
||||
|
||||
// A ticket carrying more comments than a pipe will hold, since the comment list
|
||||
// is the longest thing show prints and the last thing it reaches.
|
||||
let comments = temp
|
||||
.path()
|
||||
.join(".worklane")
|
||||
.join("comments")
|
||||
.join("00000000-0000-4000-8000-000000000000");
|
||||
fs::create_dir_all(&comments).unwrap();
|
||||
for i in 0..800 {
|
||||
fs::write(
|
||||
comments.join(format!("2026082{}_120000_{:06}.md", i % 10, i)),
|
||||
format!(
|
||||
"**Comment**\nA comment body long enough to be worth buffering, number {}.\n\n\
|
||||
**Author**: someone\n**Time**: 2026-08-20 12:00:00\n",
|
||||
i
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let output = run_with_stdout_dropped(&dir, &["show", "00000000-0000-4000"]);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
assert!(!panic_text(&stderr), "stderr was {stderr:?}");
|
||||
assert_ne!(output.status.code(), Some(101), "panicked instead of dying");
|
||||
assert_eq!(
|
||||
output.status.signal(),
|
||||
Some(SIGPIPE),
|
||||
"expected death by SIGPIPE, got {:?}",
|
||||
output.status
|
||||
);
|
||||
}
|
||||
|
||||
/// The real invocation, through a shell into `head`, which is how this was found.
|
||||
/// Whether the writer gets far enough to notice is up to the scheduler, so this
|
||||
/// asserts only what must hold either way: `head` gets its lines and nothing
|
||||
/// alarming reaches stderr.
|
||||
#[test]
|
||||
fn a_shell_pipeline_into_head_prints_lines_and_not_a_panic() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let dir = setup_crowded_board(&temp);
|
||||
|
||||
let output = Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!("{} ls backlog | head -3", BIN_NAME))
|
||||
.current_dir(&dir)
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
assert_eq!(stdout.lines().count(), 3, "stdout was {stdout:?}");
|
||||
assert!(!panic_text(&stderr), "stderr was {stderr:?}");
|
||||
}
|
||||
|
||||
/// The reset must not touch anything else: a real failure still returns its code.
|
||||
#[test]
|
||||
fn real_exit_codes_are_unchanged() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let dir = setup_crowded_board(&temp);
|
||||
|
||||
let ok = Command::new(BIN_NAME)
|
||||
.args(["ls", "backlog"])
|
||||
.current_dir(&dir)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(ok.status.code(), Some(0));
|
||||
|
||||
let missing = Command::new(BIN_NAME)
|
||||
.args(["show", "no-such-ticket-anywhere"])
|
||||
.current_dir(&dir)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(missing.status.code(), Some(1));
|
||||
|
||||
let misuse = Command::new(BIN_NAME)
|
||||
.arg("--bogus")
|
||||
.current_dir(&dir)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(misuse.status.code(), Some(2));
|
||||
}
|
||||
+346
-11
@@ -2,7 +2,7 @@ use assert_cmd::Command;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use assert_fs::TempDir;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
@@ -23,7 +23,7 @@ fn add_creates_ticket_in_backlog() {
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Test ticket"])
|
||||
.assert()
|
||||
@@ -46,7 +46,7 @@ fn add_formats_ticket_correctly() {
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.args([
|
||||
"add",
|
||||
"--title",
|
||||
@@ -103,7 +103,7 @@ fn add_joins_multiple_descriptions() {
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.args([
|
||||
"add",
|
||||
"--title", "Multi desc ticket",
|
||||
@@ -132,7 +132,7 @@ fn add_with_optional_fields_uses_defaults() {
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Minimal ticket"])
|
||||
.assert()
|
||||
.success();
|
||||
@@ -156,13 +156,13 @@ fn add_allows_duplicate_titles() {
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Existing title"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let mut cmd2 = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd2.current_dir(&temp.path())
|
||||
cmd2.current_dir(temp.path())
|
||||
.args(["add", "--title", "Existing title"])
|
||||
.assert()
|
||||
.success();
|
||||
@@ -182,7 +182,7 @@ fn add_file_has_uuid_prefix() {
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "UUID test"])
|
||||
.assert()
|
||||
.success();
|
||||
@@ -207,7 +207,7 @@ fn add_writes_the_priority_field() {
|
||||
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(&temp.path())
|
||||
.current_dir(temp.path())
|
||||
.args(["add", "--title", "Urgent thing", "--priority", "1"])
|
||||
.assert()
|
||||
.success();
|
||||
@@ -227,7 +227,7 @@ fn add_leaves_priority_unset_when_omitted() {
|
||||
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(&temp.path())
|
||||
.current_dir(temp.path())
|
||||
.args(["add", "--title", "Whenever"])
|
||||
.assert()
|
||||
.success();
|
||||
@@ -250,7 +250,7 @@ fn add_rejects_a_level_outside_the_range() {
|
||||
// read as a flag.
|
||||
for bad in ["0", "6", "high", "-1"] {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Bad level", &format!("--priority={bad}")])
|
||||
.assert()
|
||||
.failure();
|
||||
@@ -262,3 +262,338 @@ fn add_rejects_a_level_outside_the_range() {
|
||||
let count = fs::read_dir(worklane.join("backlog")).unwrap().count();
|
||||
assert_eq!(count, 0, "a ticket was written despite a bad level");
|
||||
}
|
||||
|
||||
/// Ticket text quotes flag names constantly, and the space form is what both a
|
||||
/// person and the opencode wrapper produce. Every one of these used to be refused
|
||||
/// with "unexpected argument found", writing no ticket at all.
|
||||
#[test]
|
||||
fn add_accepts_prose_values_that_begin_with_a_hyphen() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "-t is a flag name"])
|
||||
.args(["--description", "-x does nothing"])
|
||||
.args(["--acceptance", "--print should be supported"])
|
||||
.args(["--plan", "-f skips the check"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = only_ticket(&worklane);
|
||||
|
||||
// Stored verbatim, hyphens and all
|
||||
assert!(content.contains("# -t is a flag name"), "was {content:?}");
|
||||
assert!(content.contains("-x does nothing"), "was {content:?}");
|
||||
assert!(
|
||||
content.contains("- [ ] --print should be supported"),
|
||||
"was {content:?}"
|
||||
);
|
||||
assert!(content.contains("1. -f skips the check"), "was {content:?}");
|
||||
}
|
||||
|
||||
/// The docs and the habit both use it, and it reaches the parser as one token, so
|
||||
/// it has to keep working alongside the space form.
|
||||
#[test]
|
||||
fn add_still_accepts_the_equals_form() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title=-x equals form"])
|
||||
.args(["--acceptance=--print via equals"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = only_ticket(&worklane);
|
||||
assert!(content.contains("# -x equals form"), "was {content:?}");
|
||||
assert!(
|
||||
content.contains("- [ ] --print via equals"),
|
||||
"was {content:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Never silently dropped: a value that is nothing but hyphens is content.
|
||||
#[test]
|
||||
fn add_stores_a_title_that_is_only_hyphens() {
|
||||
for bare in ["-", "--", "---"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", bare])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = only_ticket(&worklane);
|
||||
assert!(
|
||||
content.starts_with(&format!("# {}\n", bare)),
|
||||
"for {bare:?}: {content:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The other half of the trade. These arguments were deliberately left alone, so a
|
||||
/// mistyped flag there is still a usage error rather than stored text.
|
||||
#[test]
|
||||
fn add_still_rejects_a_mistyped_flag_on_a_non_prose_argument() {
|
||||
for flag in ["--due", "--priority", "--tags", "--owner"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Mistyped", flag, "--bogus"])
|
||||
.assert()
|
||||
.failure();
|
||||
|
||||
let count = fs::read_dir(worklane.join("backlog")).unwrap().count();
|
||||
assert_eq!(count, 0, "{flag} wrote a ticket anyway");
|
||||
}
|
||||
}
|
||||
|
||||
/// `add` has no positionals, so a bare `--` ends the options and whatever follows
|
||||
/// has nowhere to go. Recorded because clap's separator and a hyphen-leading value
|
||||
/// are easy to confuse.
|
||||
#[test]
|
||||
fn add_rejects_arguments_after_a_bare_separator() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Sep", "--", "--title", "second"])
|
||||
.assert()
|
||||
.failure();
|
||||
|
||||
let count = fs::read_dir(worklane.join("backlog")).unwrap().count();
|
||||
assert_eq!(count, 0);
|
||||
}
|
||||
|
||||
fn only_ticket(worklane: &Path) -> String {
|
||||
let files: Vec<_> = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.collect();
|
||||
assert_eq!(files.len(), 1, "expected exactly one ticket");
|
||||
fs::read_to_string(files[0].path()).unwrap()
|
||||
}
|
||||
|
||||
/// The contract the opencode wrapper relies on: values are joined with a single
|
||||
/// newline, so an empty value is how a paragraph break is spelled. The wrapper used
|
||||
/// to drop those blanks, collapsing every multi paragraph description into one.
|
||||
#[test]
|
||||
fn add_keeps_a_paragraph_break_in_the_description() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Two Paras"])
|
||||
.args(["--description", "First paragraph."])
|
||||
.args(["--description", ""])
|
||||
.args(["--description", "Second paragraph."])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = only_ticket(&worklane);
|
||||
assert!(
|
||||
content.contains("## Description\nFirst paragraph.\n\nSecond paragraph.\n"),
|
||||
"was {content:?}"
|
||||
);
|
||||
|
||||
// And it survives the round trip back out
|
||||
let mut show = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
show.current_dir(temp.path()).args(["show", "Two Paras"]);
|
||||
let stdout = String::from_utf8(show.assert().success().get_output().stdout.clone()).unwrap();
|
||||
assert!(
|
||||
stdout.contains("First paragraph.\n\nSecond paragraph."),
|
||||
"was {stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A break belongs between paragraphs, not against the section headings.
|
||||
#[test]
|
||||
fn add_discards_blank_descriptions_at_either_end() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Padded"])
|
||||
.args(["--description", ""])
|
||||
.args(["--description", " "])
|
||||
.args(["--description", "The only line."])
|
||||
.args(["--description", ""])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = only_ticket(&worklane);
|
||||
assert!(
|
||||
content.contains("## Description\nThe only line.\n\n## Acceptance Criteria"),
|
||||
"was {content:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Nothing but blanks is no description, not an empty section.
|
||||
#[test]
|
||||
fn add_treats_an_all_blank_description_as_none() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["add", "--title", "Blank"])
|
||||
.args(["--description", ""])
|
||||
.args(["--description", " "])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = only_ticket(&worklane);
|
||||
assert!(
|
||||
content.contains("## Description\n_No description provided._"),
|
||||
"was {content:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The help, the README and the skill all promise `YYYY-MM-DD`, and until this the
|
||||
/// value was written to the ticket whatever it said.
|
||||
#[test]
|
||||
fn add_stores_a_valid_due_date_unchanged() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", "2026-08-29"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = read_only_ticket(&worklane.join("backlog"));
|
||||
assert!(content.contains("- **Due**: 2026-08-29"), "{content}");
|
||||
}
|
||||
|
||||
/// Every one of these is refused at parse time, so the exit code is 2 and nothing is
|
||||
/// written. A date that cannot happen is as wrong as a word: `2026-02-30` has the shape
|
||||
/// and is not a day.
|
||||
#[test]
|
||||
fn add_refuses_a_due_date_that_is_not_a_real_iso_date() {
|
||||
for value in ["next friday", "29-08-2026", "2026-13-01", "2026-02-30", "2026/08/29", ""] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let out = cmd
|
||||
.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", value])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.clone();
|
||||
|
||||
assert_eq!(out.status.code(), Some(2), "{value:?} was not a usage error");
|
||||
assert_eq!(
|
||||
fs::read_dir(worklane.join("backlog")).unwrap().count(),
|
||||
0,
|
||||
"{value:?} wrote a ticket anyway"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// An unpadded date parses as a date and would be stored as typed, which sorts before
|
||||
/// `2026-10-01` and is not the format anything promises.
|
||||
#[test]
|
||||
fn add_refuses_an_unpadded_due_date_rather_than_padding_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let stderr = String::from_utf8_lossy(
|
||||
&cmd.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", "2026-8-9"])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.stderr,
|
||||
)
|
||||
.to_string();
|
||||
|
||||
assert!(stderr.contains("YYYY-MM-DD"), "the error never names the format: {stderr}");
|
||||
}
|
||||
|
||||
/// An empty value keeps the message about clearing, since that is what somebody typing
|
||||
/// it is reaching for.
|
||||
#[test]
|
||||
fn an_empty_due_date_says_clearing_is_not_supported() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let stderr = String::from_utf8_lossy(
|
||||
&cmd.current_dir(temp.path())
|
||||
.arg("add")
|
||||
.args(["--title", "Dated"])
|
||||
.args(["--due", ""])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.stderr,
|
||||
)
|
||||
.to_string();
|
||||
|
||||
assert!(stderr.contains("clearing a field is not supported"), "{stderr}");
|
||||
}
|
||||
|
||||
fn read_only_ticket(dir: &Path) -> String {
|
||||
let file = fs::read_dir(dir)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.find(|e| e.path().extension().is_some_and(|ext| ext == "md"))
|
||||
.expect("no ticket written");
|
||||
|
||||
fs::read_to_string(file.path()).unwrap()
|
||||
}
|
||||
|
||||
fn chmod(path: &Path, mode: u32) {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let mut perms = fs::metadata(path).unwrap().permissions();
|
||||
perms.set_mode(mode);
|
||||
fs::set_permissions(path, perms).unwrap();
|
||||
}
|
||||
|
||||
/// A duplicate title is not a failure, so the only thing left to refuse is the write
|
||||
/// itself, and it is named with the ticket and the path rather than raised as a bare io
|
||||
/// error. The branch this replaces could not fire at all: the filename carries a fresh
|
||||
/// uuid, and its message claimed the title was taken.
|
||||
#[test]
|
||||
fn add_names_the_ticket_and_the_path_when_the_write_fails() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let backlog = worklane.join("backlog");
|
||||
|
||||
chmod(&backlog, 0o555);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let assert = cmd
|
||||
.current_dir(temp.path())
|
||||
.args(["add", "--title", "Unwritable"])
|
||||
.assert()
|
||||
.failure();
|
||||
|
||||
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
|
||||
assert!(stderr.contains("Unwritable"), "{stderr}");
|
||||
assert!(stderr.contains("unwritable.md"), "{stderr}");
|
||||
assert!(!stderr.contains("already exists"), "{stderr}");
|
||||
|
||||
chmod(&backlog, 0o755);
|
||||
assert_eq!(fs::read_dir(&backlog).unwrap().count(), 0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,602 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
/// Two campaigns, so a filter has something to exclude, and three tickets: one in each
|
||||
/// campaign and one in neither.
|
||||
const CAMP_A: &str = "aa11bb22-33cc-4dd4-8ee5-ff6677889900";
|
||||
const CAMP_B: &str = "bb22cc33-44dd-4ee5-8ff6-001122334455";
|
||||
const MEMBER: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
|
||||
const OTHER: &str = "b1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d";
|
||||
const LONER: &str = "f1f2f3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done", "campaigns"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn slug(title: &str) -> String {
|
||||
title
|
||||
.to_lowercase()
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric() || *c == ' ' || *c == '-' || *c == '_')
|
||||
.map(|c| if c == ' ' { '-' } else { c })
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A ticket with a ticked criterion, a section the tool knows nothing about and a
|
||||
/// metadata field it has never heard of, so every test can check that an assignment
|
||||
/// leaves all three exactly as they were.
|
||||
///
|
||||
/// Deliberately carries no Campaign field: no ticket written before campaigns existed
|
||||
/// has one, and `add` still does not write one, so the insertion path is what every
|
||||
/// assignment goes through.
|
||||
fn create_ticket(worklane: &Path, status: &str, title: &str, uuid: &str) -> PathBuf {
|
||||
let path = worklane
|
||||
.join(status)
|
||||
.join(format!("{}_{}.md", uuid, slug(title)));
|
||||
|
||||
fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"# {title}\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
Prose that mentions **Campaign**: not a field, in the body.\n\
|
||||
\n\
|
||||
## Acceptance Criteria\n\
|
||||
- [x] Crit one\n\
|
||||
\n\
|
||||
## Implementation Plan\n\
|
||||
1. Step one\n\
|
||||
\n\
|
||||
## Notes\n\
|
||||
A handwritten note the tool knows nothing about.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {uuid}\n\
|
||||
- **Priority**: 3\n\
|
||||
- **Tags**: alpha\n\
|
||||
- **Due**: _Not set_\n\
|
||||
- **Handled By Team**: ops\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n\
|
||||
- **Status**: {status}\n"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
fn create_campaign(worklane: &Path, title: &str, uuid: &str) -> PathBuf {
|
||||
let path = worklane
|
||||
.join("campaigns")
|
||||
.join(format!("{}_{}.md", uuid, slug(title)));
|
||||
|
||||
fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"# {title}\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
What has to ship together.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {uuid}\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
fn board(temp: &TempDir) -> PathBuf {
|
||||
let worklane = setup_worklane(temp);
|
||||
create_campaign(&worklane, "v1 release", CAMP_A);
|
||||
create_campaign(&worklane, "v2 release", CAMP_B);
|
||||
create_ticket(&worklane, "backlog", "The member", MEMBER);
|
||||
create_ticket(&worklane, "done", "The other member", OTHER);
|
||||
create_ticket(&worklane, "backlog", "The loner", LONER);
|
||||
worklane
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn stdout(out: &std::process::Output) -> String {
|
||||
String::from_utf8_lossy(&out.stdout).to_string()
|
||||
}
|
||||
|
||||
fn stderr(out: &std::process::Output) -> String {
|
||||
String::from_utf8_lossy(&out.stderr).to_string()
|
||||
}
|
||||
|
||||
fn find(worklane: &Path, uuid: &str) -> PathBuf {
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
for entry in fs::read_dir(worklane.join(status))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
{
|
||||
if entry.file_name().to_string_lossy().starts_with(uuid) {
|
||||
return entry.path();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
panic!("no file for ticket {uuid}");
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path, uuid: &str) -> String {
|
||||
fs::read_to_string(find(worklane, uuid)).unwrap()
|
||||
}
|
||||
|
||||
fn campaigns(worklane: &Path) -> Vec<String> {
|
||||
let mut names: Vec<String> = fs::read_dir(worklane.join("campaigns"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().to_string_lossy().to_string())
|
||||
.collect();
|
||||
names.sort();
|
||||
names
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ filing one --
|
||||
|
||||
#[test]
|
||||
fn campaign_add_writes_a_uuid_title_description_and_metadata() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"campaign",
|
||||
"add",
|
||||
"--title",
|
||||
"v1 release",
|
||||
"--description",
|
||||
"Everything that ships together.",
|
||||
"--owner",
|
||||
"alice",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let names = campaigns(&worklane);
|
||||
assert_eq!(names.len(), 1, "{names:?}");
|
||||
let name = &names[0];
|
||||
assert!(name.ends_with("_v1-release.md"), "{name}");
|
||||
|
||||
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
|
||||
assert!(content.starts_with("# v1 release\n"), "{content}");
|
||||
assert!(content.contains("Everything that ships together."), "{content}");
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
assert!(content.contains("- **Created At**: 20"), "{content}");
|
||||
|
||||
// The uuid in the file is the one in the filename, since that is what `assign`
|
||||
// stores and what every lookup compares against.
|
||||
let uuid = name.split('_').next().unwrap();
|
||||
assert!(content.contains(&format!("- **ID**: {uuid}")), "{content}");
|
||||
}
|
||||
|
||||
/// A campaign has no status, so its file carries none. A Status field would be a second
|
||||
/// place for a state that is derived, and the two would disagree the moment a member
|
||||
/// moved.
|
||||
#[test]
|
||||
fn a_campaign_carries_no_status_and_no_criteria() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
run(&temp, &["campaign", "add", "--title", "v1 release"]);
|
||||
|
||||
let name = campaigns(&worklane).remove(0);
|
||||
let content = fs::read_to_string(worklane.join("campaigns").join(name)).unwrap();
|
||||
|
||||
assert!(!content.contains("**Status**"), "{content}");
|
||||
assert!(!content.contains("Acceptance Criteria"), "{content}");
|
||||
assert!(!content.contains("Implementation Plan"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_is_created_without_a_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "add", "--description", "No title here."]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(2), "{}", stderr(&out));
|
||||
assert!(campaigns(&worklane).is_empty(), "{:?}", campaigns(&worklane));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn init_creates_the_campaigns_directory() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&temp, &["init"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
assert!(temp.child(".worklane").child("campaigns").path().is_dir());
|
||||
}
|
||||
|
||||
/// A board made before campaigns existed has no such directory, and a `worklane init`
|
||||
/// over a live board to get one would be a strange thing to have to do.
|
||||
#[test]
|
||||
fn the_campaigns_directory_is_created_for_a_board_that_predates_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
assert!(!worklane.child("campaigns").path().exists());
|
||||
|
||||
let out = run(&temp, &["campaign", "add", "--title", "v1 release"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
assert_eq!(campaigns(worklane.path()).len(), 1);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------- assigning --
|
||||
|
||||
#[test]
|
||||
fn assign_writes_the_campaign_field_in_the_metadata_section() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
assert!(content.contains(&format!("- **Campaign**: {CAMP_A}")), "{content}");
|
||||
|
||||
// Scoped to the section: the description quotes the marker, and the field has to
|
||||
// land under the heading rather than over the prose.
|
||||
let metadata = content.split("## Metadata").nth(1).unwrap();
|
||||
assert!(metadata.contains(&format!("- **Campaign**: {CAMP_A}")), "{content}");
|
||||
assert!(
|
||||
content.contains("Prose that mentions **Campaign**: not a field, in the body."),
|
||||
"the description was rewritten: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The field goes in its place among the others rather than at the end, so Status stays
|
||||
/// last, which is where every file already keeps it.
|
||||
#[test]
|
||||
fn the_field_is_inserted_before_status() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
let campaign_at = content.find("- **Campaign**:").unwrap();
|
||||
let status_at = content.find("- **Status**:").unwrap();
|
||||
assert!(campaign_at < status_at, "{content}");
|
||||
}
|
||||
|
||||
/// All three tiers, since a campaign is addressed the way a ticket is: a uuid prefix, a
|
||||
/// title substring, and a substring reaching the middle of the filename.
|
||||
#[test]
|
||||
fn a_campaign_resolves_by_uuid_prefix_title_or_filename() {
|
||||
for search in ["aa11", "v1 release", "4dd4"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["assign", search, MEMBER]);
|
||||
assert!(out.status.success(), "{search}: {}", stderr(&out));
|
||||
assert!(
|
||||
ticket(&worklane, MEMBER).contains(&format!("- **Campaign**: {CAMP_A}")),
|
||||
"{search}: {}",
|
||||
ticket(&worklane, MEMBER)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ticket_names_at_most_one_campaign() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
let out = run(&temp, &["assign", "v2 release", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
assert_eq!(
|
||||
content.matches("- **Campaign**:").count(),
|
||||
1,
|
||||
"reassigning added a second field: {content}"
|
||||
);
|
||||
assert!(content.contains(&format!("- **Campaign**: {CAMP_B}")), "{content}");
|
||||
assert!(!content.contains(CAMP_A), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assigning_the_campaign_already_named_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
let before = ticket(&worklane, MEMBER);
|
||||
|
||||
let out = run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
assert!(stdout(&out).contains("already in campaign"), "{}", stdout(&out));
|
||||
assert_eq!(ticket(&worklane, MEMBER), before);
|
||||
}
|
||||
|
||||
/// The campaign is resolved before the ticket is touched, so a call naming a good
|
||||
/// ticket and a campaign that does not exist writes nothing at all.
|
||||
#[test]
|
||||
fn an_unknown_campaign_leaves_the_ticket_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, MEMBER);
|
||||
|
||||
let out = run(&temp, &["assign", "v9 release", MEMBER]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
assert!(stderr(&out).contains("No campaign found matching"), "{}", stderr(&out));
|
||||
assert_eq!(ticket(&worklane, MEMBER), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn content_the_tool_does_not_know_survives_an_assignment() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
|
||||
let content = ticket(&worklane, MEMBER);
|
||||
assert!(content.contains("## Notes"), "{content}");
|
||||
assert!(
|
||||
content.contains("A handwritten note the tool knows nothing about."),
|
||||
"{content}"
|
||||
);
|
||||
assert!(content.contains("- **Handled By Team**: ops"), "{content}");
|
||||
// And the ticked criterion is still ticked.
|
||||
assert!(content.contains("- [x] Crit one"), "{content}");
|
||||
}
|
||||
|
||||
/// One field, one writer. `assign` owns Campaign the way `chown` owns Owner.
|
||||
#[test]
|
||||
fn neither_add_nor_set_offers_a_campaign_flag() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let added = run(&temp, &["add", "--title", "New one", "--campaign", "v1 release"]);
|
||||
assert_eq!(added.status.code(), Some(2), "{}", stderr(&added));
|
||||
|
||||
let set = run(&temp, &["set", MEMBER, "--campaign", "v1 release"]);
|
||||
assert_eq!(set.status.code(), Some(2), "{}", stderr(&set));
|
||||
|
||||
// The stored shape, not the bare marker: the fixture description quotes the marker
|
||||
// on purpose, so an unscoped match here would pass whatever the commands did.
|
||||
assert!(!ticket(&worklane, MEMBER).contains("- **Campaign**:"));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------- reading --
|
||||
|
||||
#[test]
|
||||
fn campaign_ls_lists_campaigns_with_their_member_counts() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
run(&temp, &["assign", "v1 release", OTHER]);
|
||||
|
||||
let out = run(&temp, &["campaign", "ls"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let listing = stdout(&out);
|
||||
// One of the two members is in done, so the campaign is open and half finished.
|
||||
assert!(listing.contains("v1 release | 1/2 done [open]"), "{listing}");
|
||||
// Nothing has been filed against the other one.
|
||||
assert!(listing.contains("v2 release | no members"), "{listing}");
|
||||
}
|
||||
|
||||
/// A campaign is done when it holds members and every one of them is done. An empty one
|
||||
/// is neither, which is why it reads `no members` rather than `0/0 done`.
|
||||
#[test]
|
||||
fn a_campaign_whose_every_member_is_done_reads_done() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", OTHER]);
|
||||
|
||||
let listing = stdout(&run(&temp, &["campaign", "ls"]));
|
||||
assert!(listing.contains("v1 release | 1/1 done [done]"), "{listing}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn campaign_show_prints_the_body_and_the_members_grouped_by_status() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
run(&temp, &["assign", "v1 release", OTHER]);
|
||||
|
||||
let out = run(&temp, &["campaign", "show", "aa11"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let shown = stdout(&out);
|
||||
assert!(shown.contains("v1 release"), "{shown}");
|
||||
assert!(shown.contains("What has to ship together."), "{shown}");
|
||||
assert!(shown.contains("1/2 done"), "{shown}");
|
||||
assert!(shown.contains("[BACKLOG]"), "{shown}");
|
||||
assert!(shown.contains("The member"), "{shown}");
|
||||
// Done members are shown here, unlike in `ls`: what is finished against what is
|
||||
// left is the whole question a campaign asks.
|
||||
assert!(shown.contains("[DONE]"), "{shown}");
|
||||
assert!(shown.contains("The other member"), "{shown}");
|
||||
// And a ticket in no campaign is not a member of this one.
|
||||
assert!(!shown.contains("The loner"), "{shown}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ls_campaign_lists_only_that_campaigns_members() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
run(&temp, &["assign", "v2 release", LONER]);
|
||||
|
||||
let out = run(&temp, &["ls", "--campaign", "v1 release"]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let listing = stdout(&out);
|
||||
assert!(listing.contains("The member"), "{listing}");
|
||||
assert!(!listing.contains("The loner"), "{listing}");
|
||||
assert!(listing.contains("[BACKLOG] 1 ticket"), "{listing}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ls_campaign_refuses_a_campaign_that_does_not_exist() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["ls", "--campaign", "v9 release"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
assert!(stderr(&out).contains("No campaign found matching"), "{}", stderr(&out));
|
||||
}
|
||||
|
||||
/// The stored value is a full uuid, so a campaign that has been deleted has to be
|
||||
/// reported as gone rather than shown raw, the way a dangling relation target is.
|
||||
#[test]
|
||||
fn a_campaign_that_no_longer_exists_reads_as_missing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
fs::remove_file(worklane.join("campaigns").join(format!("{CAMP_A}_v1-release.md"))).unwrap();
|
||||
|
||||
let out = run(&temp, &["show", MEMBER]);
|
||||
assert!(out.status.success(), "{}", stderr(&out));
|
||||
|
||||
let shown = stdout(&out);
|
||||
assert!(shown.contains("_missing_"), "{shown}");
|
||||
// The short id survives, since it is the only thing left to go looking for.
|
||||
assert!(shown.contains("(aa11bb2)"), "{shown}");
|
||||
assert!(!shown.contains(CAMP_A), "the bare uuid was shown: {shown}");
|
||||
}
|
||||
|
||||
/// The title is shown rather than the uuid the file stores: thirty-six characters of
|
||||
/// hex in a metadata table say nothing about which campaign it is.
|
||||
#[test]
|
||||
fn a_ticket_shows_the_campaign_title_not_its_uuid() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
run(&temp, &["assign", "v1 release", MEMBER]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", MEMBER]));
|
||||
assert!(shown.contains("(aa11bb2) v1 release"), "{shown}");
|
||||
assert!(!shown.contains(CAMP_A), "{shown}");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------- not a ticket --
|
||||
|
||||
/// A campaign is in no status directory, so `mv` has nothing to move. It says so rather
|
||||
/// than reporting a ticket it could not find, which would send the caller hunting for a
|
||||
/// typo in a name that is perfectly correct.
|
||||
#[test]
|
||||
fn mv_refuses_a_campaign() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["mv", "v1 release", "--status", "committed"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
let message = stderr(&out);
|
||||
assert!(message.contains("is a campaign, not a ticket"), "{message}");
|
||||
assert!(message.contains("no status directory"), "{message}");
|
||||
|
||||
// And it stayed where it was: nothing was moved into a status directory.
|
||||
assert!(
|
||||
worklane
|
||||
.join("campaigns")
|
||||
.join(format!("{CAMP_A}_v1-release.md"))
|
||||
.exists()
|
||||
);
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
let moved = fs::read_dir(worklane.join(status))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.any(|e| e.file_name().to_string_lossy().starts_with(CAMP_A));
|
||||
assert!(!moved, "a campaign reached the {status} directory");
|
||||
}
|
||||
}
|
||||
|
||||
/// Every command that takes a ticket gives the same explanation, because the refusal is
|
||||
/// in resolution rather than in `mv`.
|
||||
#[test]
|
||||
fn a_campaign_is_refused_wherever_a_ticket_is_expected() {
|
||||
for args in [
|
||||
vec!["show", "v1 release"],
|
||||
vec!["comment", "v1 release", "A note."],
|
||||
vec!["chown", "bob", "v1 release"],
|
||||
] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &args);
|
||||
assert!(!out.status.success(), "{args:?}");
|
||||
assert!(
|
||||
stderr(&out).contains("is a campaign, not a ticket"),
|
||||
"{args:?}: {}",
|
||||
stderr(&out)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A search that names neither still says nothing was found, rather than complaining
|
||||
/// about a directory the caller never mentioned.
|
||||
#[test]
|
||||
fn a_search_that_names_nothing_still_reports_no_ticket() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["show", "nothing at all"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
assert!(
|
||||
stderr(&out).contains("No ticket found matching"),
|
||||
"{}",
|
||||
stderr(&out)
|
||||
);
|
||||
}
|
||||
|
||||
/// A campaign resolves by the same tiers a ticket does, so it can be ambiguous the same
|
||||
/// way, and the listing has to name campaigns rather than tickets.
|
||||
#[test]
|
||||
fn an_ambiguous_campaign_lists_the_candidates() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let _worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["campaign", "show", "release"]);
|
||||
|
||||
assert!(!out.status.success());
|
||||
let message = stderr(&out);
|
||||
assert!(message.contains("Multiple campaigns found matching"), "{message}");
|
||||
assert!(message.contains("v1 release"), "{message}");
|
||||
assert!(message.contains("v2 release"), "{message}");
|
||||
}
|
||||
@@ -0,0 +1,560 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
const UUID: &str = "475534a3-8a0d-45cb-9a97-39c251dd8e39";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
/// One criterion already ticked, one handwritten line inside the section, and a
|
||||
/// checkbox in the description that must not be counted as a criterion.
|
||||
fn create_ticket(worklane: &Path) {
|
||||
// Written without line continuations on purpose: a trailing `\` strips the next
|
||||
// line's leading whitespace, so the indented line would arrive unindented and the
|
||||
// test would prove nothing about preserving it.
|
||||
let lines = [
|
||||
"# Check me",
|
||||
"",
|
||||
"## Description",
|
||||
"- [ ] A checkbox in the description, which is not a criterion.",
|
||||
"",
|
||||
"## Acceptance Criteria",
|
||||
"- [ ] alpha shared",
|
||||
"- [x] beta alone",
|
||||
" A handwritten line inside the section.",
|
||||
"- [ ] gamma shared",
|
||||
"",
|
||||
"## Implementation Plan",
|
||||
"1. Step one",
|
||||
"",
|
||||
"## Metadata",
|
||||
"",
|
||||
&format!("- **ID**: {}", UUID),
|
||||
"- **Status**: backlog",
|
||||
"",
|
||||
];
|
||||
|
||||
fs::write(
|
||||
worklane.join("backlog").join(format!("{}_check-me.md", UUID)),
|
||||
lines.join("\n"),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// A second ticket whose criteria carry the word `all`, so the keyword's precedence
|
||||
/// can be pinned without renumbering the shared fixture.
|
||||
const ALL_UUID: &str = "6b1f9c22-0d4e-4a1b-9f37-2c85ab4d1e70";
|
||||
|
||||
fn create_all_in_text_ticket(worklane: &Path) {
|
||||
let lines = [
|
||||
"# All in the text",
|
||||
"",
|
||||
"## Acceptance Criteria",
|
||||
"- [ ] all the boxes are listed",
|
||||
"- [ ] the footer is drawn",
|
||||
"",
|
||||
"## Metadata",
|
||||
"",
|
||||
&format!("- **ID**: {}", ALL_UUID),
|
||||
"- **Status**: backlog",
|
||||
"",
|
||||
];
|
||||
|
||||
fs::write(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join(format!("{}_all-in-the-text.md", ALL_UUID)),
|
||||
lines.join("\n"),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn all_in_text_ticket(worklane: &Path) -> String {
|
||||
fs::read_to_string(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join(format!("{}_all-in-the-text.md", ALL_UUID)),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path) -> String {
|
||||
fs::read_to_string(worklane.join("backlog").join(format!("{}_check-me.md", UUID))).unwrap()
|
||||
}
|
||||
|
||||
/// The whole point: one line changes and every other keeps its state.
|
||||
#[test]
|
||||
fn check_ticks_one_criterion_by_index() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [x] beta alone\n"), "beta lost its tick: {content}");
|
||||
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_ticks_one_criterion_by_substring() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", UUID, "GAMMA"]);
|
||||
assert!(ticket(&worklane).contains("- [x] gamma shared\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uncheck_unticks_one_criterion() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["uncheck", UUID, "2"]);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [ ] beta alone\n"), "{content}");
|
||||
assert!(content.contains("- [ ] alpha shared\n"), "{content}");
|
||||
}
|
||||
|
||||
/// The handwritten line sits between two criteria, so it is the thing most likely to
|
||||
/// be lost by a rewrite, and it must not take a number either.
|
||||
#[test]
|
||||
fn a_handwritten_line_in_the_section_survives_and_is_not_numbered() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
// gamma is the third criterion even though it is the fourth line of the section
|
||||
run(&temp, &["check", UUID, "3"]);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] gamma shared\n"), "{content}");
|
||||
assert!(
|
||||
content.contains(" A handwritten line inside the section.\n"),
|
||||
"the handwritten line was lost or reindented: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A checkbox outside the section is not a criterion, so the numbering starts inside it.
|
||||
#[test]
|
||||
fn a_checkbox_in_the_description_is_not_a_criterion() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", UUID, "1"]);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(
|
||||
content.contains("- [ ] A checkbox in the description, which is not a criterion.\n"),
|
||||
"the description checkbox was ticked: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checking_an_already_checked_criterion_changes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "2"]);
|
||||
assert!(out.status.success());
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stdout).contains("Already checked"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
|
||||
}
|
||||
|
||||
/// The listed numbers have to be the real ones, or the advice to use the number points
|
||||
/// at the wrong criterion. alpha and gamma are 1 and 3, never 1 and 2.
|
||||
#[test]
|
||||
fn an_ambiguous_substring_lists_the_matches_with_their_real_numbers() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "shared"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("matches 2 criteria"), "{stderr:?}");
|
||||
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
|
||||
assert!(stderr.contains("3. [ ] gamma shared"), "{stderr:?}");
|
||||
assert!(!stderr.contains("2. [ ] gamma"), "renumbered: {stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_substring_matching_nothing_is_an_error_listing_the_criteria() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "nowhere"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("No criterion"), "{stderr:?}");
|
||||
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// A number out of range is a bad index, not a substring that happened to miss.
|
||||
#[test]
|
||||
fn an_index_out_of_range_says_so() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "9"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("is not one of the 3 criteria"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// No terminal to prompt at, so the list comes back as an error instead. This is the
|
||||
/// path the opencode wrapper takes, and it must not block on stdin.
|
||||
#[test]
|
||||
fn omitting_the_criterion_without_a_terminal_returns_the_list_as_an_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("Which criterion"), "{stderr:?}");
|
||||
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
|
||||
assert!(stderr.contains("2. [x] beta alone"), "{stderr:?}");
|
||||
assert!(stderr.contains("3. [ ] gamma shared"), "{stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ticket_with_no_criteria_says_so() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
fs::write(
|
||||
worklane.join("backlog").join("aaaaaaaa-0000-4000-8000-000000000000_bare.md"),
|
||||
"# Bare\n\n## Acceptance Criteria\n_No acceptance criteria provided._\n\n## Metadata\n\n- **ID**: aaaaaaaa-0000-4000-8000-000000000000\n- **Status**: backlog\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let out = run(&temp, &["check", "aaaaaaaa", "1"]);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("no acceptance criteria"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
/// show numbers the criteria, so the index check takes is visible where it is read.
|
||||
#[test]
|
||||
fn show_numbers_the_criteria() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["show", UUID]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert!(stdout.contains("1. [ ] alpha shared"), "{stdout:?}");
|
||||
assert!(stdout.contains("2. [x] beta alone"), "{stdout:?}");
|
||||
assert!(stdout.contains("3. [ ] gamma shared"), "{stdout:?}");
|
||||
|
||||
// The handwritten line is shown but takes no number
|
||||
assert!(stdout.contains(" A handwritten line inside the section."), "{stdout:?}");
|
||||
assert!(!stdout.contains("4. ["), "the handwritten line was numbered: {stdout:?}");
|
||||
|
||||
// And the description checkbox is left as it is, outside the numbering
|
||||
assert!(
|
||||
stdout.contains("- [ ] A checkbox in the description"),
|
||||
"{stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_leaves_nothing_behind() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", UUID, "1"]);
|
||||
|
||||
let strays: Vec<String> = fs::read_dir(&worklane)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.filter(|name| {
|
||||
!["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str())
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(strays, Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// The common case the batch exists for: the work is done, every box is true.
|
||||
#[test]
|
||||
fn all_ticks_every_criterion() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "all"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [x] beta alone\n"), "{content}");
|
||||
assert!(content.contains("- [x] gamma shared\n"), "{content}");
|
||||
|
||||
// beta was already ticked, so it is reported unchanged rather than as a new mark
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(stdout.contains("Checked 1: alpha shared"), "{stdout:?}");
|
||||
assert!(stdout.contains("Already checked 2: beta alone"), "{stdout:?}");
|
||||
assert!(stdout.contains("Checked 3: gamma shared"), "{stdout:?}");
|
||||
|
||||
// And nothing outside the section was touched
|
||||
assert!(
|
||||
content.contains("- [ ] A checkbox in the description, which is not a criterion.\n"),
|
||||
"the description checkbox was ticked: {content}"
|
||||
);
|
||||
assert!(
|
||||
content.contains(" A handwritten line inside the section.\n"),
|
||||
"the handwritten line was lost: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// An index and a substring in one call, each addressed by the existing rules.
|
||||
#[test]
|
||||
fn one_call_takes_several_mixed_terms() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "3", "ALPHA"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [x] gamma shared\n"), "{content}");
|
||||
|
||||
// Reported in show's order whatever order the terms arrived in
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
let alpha = stdout.find("Checked 1: alpha");
|
||||
let gamma = stdout.find("Checked 3: gamma");
|
||||
assert!(
|
||||
matches!((alpha, gamma), (Some(alpha), Some(gamma)) if alpha < gamma),
|
||||
"reported out of order, or one of them is missing: {stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The same criterion named twice, once by number and once by text, is one mark and
|
||||
/// one line of output.
|
||||
#[test]
|
||||
fn a_criterion_named_twice_is_reported_once() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "alpha", "all"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert_eq!(
|
||||
stdout.matches("alpha shared").count(),
|
||||
1,
|
||||
"alpha was reported more than once: {stdout:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
stdout.lines().count(),
|
||||
3,
|
||||
"one line per criterion, not per term: {stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Nothing to change, so nothing is written, the way a single already-ticked
|
||||
/// criterion already behaves.
|
||||
#[test]
|
||||
fn a_batch_that_would_change_nothing_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", UUID, "all"]);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "all"]);
|
||||
assert!(out.status.success());
|
||||
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert_eq!(
|
||||
stdout.matches("Already checked").count(),
|
||||
3,
|
||||
"{stdout:?}"
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
|
||||
}
|
||||
|
||||
/// One term that matches nothing refuses the whole call, so the ticket is never left
|
||||
/// half-marked.
|
||||
#[test]
|
||||
fn a_term_matching_nothing_leaves_the_batch_unwritten() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "nowhere", "3"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("nowhere"), "the term was not named: {stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before, "alpha was ticked anyway");
|
||||
}
|
||||
|
||||
/// An ambiguous term in a batch is refused the same way a lone one is, and names
|
||||
/// itself rather than whichever term happened to come first.
|
||||
#[test]
|
||||
fn an_ambiguous_term_in_a_batch_names_itself_and_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "shared"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("'shared' matches 2 criteria"), "{stderr:?}");
|
||||
assert!(stderr.contains("1. [ ] alpha shared"), "{stderr:?}");
|
||||
assert!(stderr.contains("3. [ ] gamma shared"), "{stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// An index out of range in a batch is still a bad index, not a failed text search.
|
||||
#[test]
|
||||
fn an_index_out_of_range_in_a_batch_leaves_the_file_untouched() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["check", UUID, "1", "9"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(stderr.contains("is not one of the 3 criteria"), "{stderr:?}");
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// The decision this pins: `all` is the keyword, checked before the substring the way
|
||||
/// the index is, so it ticks every criterion and not the one whose text says "all".
|
||||
#[test]
|
||||
fn all_is_the_keyword_and_not_a_substring_of_the_text() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_all_in_text_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", ALL_UUID, "all"]);
|
||||
|
||||
let content = all_in_text_ticket(&worklane);
|
||||
assert!(content.contains("- [x] all the boxes are listed\n"), "{content}");
|
||||
assert!(
|
||||
content.contains("- [x] the footer is drawn\n"),
|
||||
"all matched its own text instead of every criterion: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
/// And the criterion whose text carries the word is still reachable, by its number or
|
||||
/// by a longer substring.
|
||||
#[test]
|
||||
fn a_criterion_whose_text_contains_all_is_still_reachable() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_all_in_text_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", ALL_UUID, "all the boxes"]);
|
||||
|
||||
let content = all_in_text_ticket(&worklane);
|
||||
assert!(content.contains("- [x] all the boxes are listed\n"), "{content}");
|
||||
assert!(content.contains("- [ ] the footer is drawn\n"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uncheck_takes_all() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["uncheck", UUID, "all"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [ ] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [ ] beta alone\n"), "{content}");
|
||||
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
|
||||
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(stdout.contains("Unchecked 2: beta alone"), "{stdout:?}");
|
||||
assert!(stdout.contains("Already unchecked 1: alpha shared"), "{stdout:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uncheck_takes_several_mixed_terms() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["check", UUID, "all"]);
|
||||
let out = run(&temp, &["uncheck", UUID, "2", "gamma"]);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] alpha shared\n"), "{content}");
|
||||
assert!(content.contains("- [ ] beta alone\n"), "{content}");
|
||||
assert!(content.contains("- [ ] gamma shared\n"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_failing_term_refuses_an_uncheck_batch_too() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["uncheck", UUID, "2", "nowhere"]);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert_eq!(ticket(&worklane), before, "beta was unticked anyway");
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
const UUID: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
/// A fully populated ticket, with one criterion already ticked and a section the tool
|
||||
/// knows nothing about, so every test can check both survive.
|
||||
fn create_ticket(worklane: &Path) {
|
||||
fs::write(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join(format!("{}_original-title.md", UUID)),
|
||||
format!(
|
||||
"# Original title\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
The **Owner**: line quoted here is prose, not metadata.\n\
|
||||
\n\
|
||||
## Acceptance Criteria\n\
|
||||
- [x] Crit one\n\
|
||||
- [ ] Crit two\n\
|
||||
\n\
|
||||
## Implementation Plan\n\
|
||||
1. Step one\n\
|
||||
\n\
|
||||
## Notes\n\
|
||||
A handwritten note the tool knows nothing about.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {}\n\
|
||||
- **Priority**: 3\n\
|
||||
- **Tags**: alpha\n\
|
||||
- **Due**: 2026-09-01\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n\
|
||||
- **Status**: backlog\n",
|
||||
UUID
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path) -> String {
|
||||
let entry = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.find(|e| e.file_name().to_string_lossy().ends_with(".md"))
|
||||
.expect("no ticket file");
|
||||
fs::read_to_string(entry.path()).unwrap()
|
||||
}
|
||||
|
||||
fn stray_files(worklane: &Path) -> Vec<String> {
|
||||
fs::read_dir(worklane)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.filter(|name| {
|
||||
!["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chown_sets_the_owner() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "bob", UUID]);
|
||||
assert!(
|
||||
out.status.success(),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stdout).contains("owner"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- **Owner**: bob"), "{content}");
|
||||
|
||||
// Every other field is left as it was
|
||||
assert!(content.contains("- **Priority**: 3"), "{content}");
|
||||
assert!(content.contains("- **Tags**: alpha"), "{content}");
|
||||
assert!(content.contains("- **Due**: 2026-09-01"), "{content}");
|
||||
assert!(content.contains("- **Status**: backlog"), "{content}");
|
||||
}
|
||||
|
||||
/// The value is free text, matching `add --owner`, and is checked against nothing:
|
||||
/// not git, not a list of users.
|
||||
#[test]
|
||||
fn chown_accepts_any_user_without_validating_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "Nobody At All", UUID]);
|
||||
|
||||
assert!(
|
||||
ticket(&worklane).contains("- **Owner**: Nobody At All"),
|
||||
"{}",
|
||||
ticket(&worklane)
|
||||
);
|
||||
}
|
||||
|
||||
/// The tick and the unknown section are what a regenerated file would lose, and the
|
||||
/// quoted `**Owner**:` line in the description is what an unscoped rewrite would take
|
||||
/// instead of the real field.
|
||||
#[test]
|
||||
fn chown_leaves_everything_it_was_not_asked_about_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "bob", UUID]);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(
|
||||
content.contains("- [x] Crit one"),
|
||||
"the tick was lost: {content}"
|
||||
);
|
||||
assert!(
|
||||
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
|
||||
"the unknown section was lost: {content}"
|
||||
);
|
||||
assert!(
|
||||
content.contains("The **Owner**: line quoted here is prose, not metadata.\n"),
|
||||
"the prose was rewritten as metadata: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chown_reports_no_change_and_leaves_the_file_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "alice", UUID]);
|
||||
assert!(out.status.success());
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stdout).contains("No changes"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
|
||||
}
|
||||
|
||||
/// Resolution is `resolve_ticket`, the same as `mv` and `comment`, so all three tiers
|
||||
/// reach the ticket. The filename search reaches the middle of the uuid, which the
|
||||
/// prefix tier cannot.
|
||||
#[test]
|
||||
fn chown_resolves_a_uuid_prefix_a_title_or_a_filename() {
|
||||
for search in ["641e", "Original", "4d2f"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "bob", search]);
|
||||
assert!(
|
||||
out.status.success(),
|
||||
"{search} did not resolve: {:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(
|
||||
ticket(&worklane).contains("- **Owner**: bob"),
|
||||
"{search}: {}",
|
||||
ticket(&worklane)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The swap is left to resolution rather than checked for: the username has to resolve
|
||||
/// as a ticket, and a bare one does not.
|
||||
#[test]
|
||||
fn chown_refuses_a_swapped_call() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", UUID, "bob"]);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("No ticket found matching 'bob'"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// An empty user looks like a way to clear the field, and clearing is not supported.
|
||||
#[test]
|
||||
fn chown_refuses_an_empty_user_as_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["chown", "", UUID]);
|
||||
assert_eq!(out.status.code(), Some(2));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("clearing a field is not supported"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// A hand-made ticket without the field is refused rather than guessed at, the same
|
||||
/// as every other metadata field.
|
||||
#[test]
|
||||
fn chown_refuses_a_ticket_with_no_owner_field() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
fs::write(
|
||||
worklane.join("backlog").join(format!("{}_bare.md", UUID)),
|
||||
format!("# Bare\n\n## Metadata\n\n- **ID**: {}\n", UUID),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let out = run(&temp, &["chown", "bob", UUID]);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("has no Owner field"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
/// The staged temp file is renamed into place, so a completed write leaves nothing to
|
||||
/// be read as a stray ticket.
|
||||
#[test]
|
||||
fn chown_leaves_nothing_behind() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "bob", UUID]);
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// The file keeps its name: the slug follows the title, and the owner is not in it.
|
||||
#[test]
|
||||
fn chown_does_not_rename_the_file() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["chown", "bob", UUID]);
|
||||
|
||||
let names: Vec<String> = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.collect();
|
||||
assert_eq!(names, vec![format!("{}_original-title.md", UUID)]);
|
||||
}
|
||||
+100
-11
@@ -2,7 +2,7 @@ use assert_cmd::Command;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use assert_fs::TempDir;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
@@ -18,7 +18,7 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
}
|
||||
|
||||
fn create_ticket(
|
||||
worklane_dir: &PathBuf,
|
||||
worklane_dir: &Path,
|
||||
status: &str,
|
||||
title: &str,
|
||||
) -> String {
|
||||
@@ -53,7 +53,7 @@ fn comment_creates_file_with_valid_ticket_uuid() {
|
||||
let uuid = create_ticket(&worklane, "backlog", "Test Ticket");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args([&uuid, "This is a test comment"])
|
||||
.assert()
|
||||
@@ -78,7 +78,7 @@ fn comment_creates_file_with_valid_ticket_title() {
|
||||
create_ticket(&worklane, "committed", "My Ticket");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args(["My Ticket", "Testing title lookup"])
|
||||
.assert()
|
||||
@@ -105,7 +105,7 @@ fn comment_includes_git_user_and_body() {
|
||||
let uuid = create_ticket(&worklane, "backlog", "Comment Test");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args([&uuid, "My comment body"])
|
||||
.assert()
|
||||
@@ -129,7 +129,7 @@ fn comment_stored_in_timestamped_file() {
|
||||
let uuid = create_ticket(&worklane, "done", "Timestamp Test");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args([&uuid, "Timestamp test"])
|
||||
.assert()
|
||||
@@ -156,7 +156,7 @@ fn comment_creates_comments_directory() {
|
||||
assert!(!comments_dir.exists());
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args([&uuid, "Create dir test"])
|
||||
.assert()
|
||||
@@ -173,7 +173,7 @@ fn comment_uses_owner_flag_when_provided() {
|
||||
let uuid = create_ticket(&worklane, "backlog", "Owner Test");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args([&uuid, "Test comment with owner"])
|
||||
.arg("-o")
|
||||
@@ -198,7 +198,7 @@ fn comment_falls_back_to_git_user_when_owner_omitted() {
|
||||
let uuid = create_ticket(&worklane, "done", "Fallback Test");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args([&uuid, "Test comment fallback"])
|
||||
.assert()
|
||||
@@ -225,7 +225,7 @@ fn comments_added_back_to_back_are_both_kept() {
|
||||
for body in ["first comment", "second comment", "third comment"] {
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(&temp.path())
|
||||
.current_dir(temp.path())
|
||||
.arg("comment")
|
||||
.args([&uuid, body])
|
||||
.assert()
|
||||
@@ -241,7 +241,7 @@ fn comments_added_back_to_back_are_both_kept() {
|
||||
|
||||
// And show has to render them in the order they were added
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg(&uuid);
|
||||
cmd.current_dir(temp.path()).arg("show").arg(&uuid);
|
||||
let assert = cmd.assert().success();
|
||||
let stdout = String::from_utf8(assert.get_output().stdout.clone()).unwrap();
|
||||
|
||||
@@ -250,3 +250,92 @@ fn comments_added_back_to_back_are_both_kept() {
|
||||
let third = stdout.find("third comment").expect("third comment missing");
|
||||
assert!(first < second && second < third, "comments out of order");
|
||||
}
|
||||
|
||||
/// The body is a positional, and the case that motivated this: a review comment
|
||||
/// quoting a flag name used to be refused outright.
|
||||
#[test]
|
||||
fn comment_accepts_a_body_that_begins_with_a_hyphen() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let uuid = create_ticket(&worklane, "backlog", "Hyphen body");
|
||||
|
||||
for body in ["--print is the flag I mean", "-f skips the check", "-"] {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["comment", &uuid, body])
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
let bodies: String = fs::read_dir(worklane.join("comments").join(&uuid))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| fs::read_to_string(e.path()).unwrap())
|
||||
.collect();
|
||||
|
||||
for body in ["--print is the flag I mean", "-f skips the check"] {
|
||||
assert!(bodies.contains(body), "{body:?} missing from {bodies:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The ticket positional was deliberately left alone, so a hyphen-leading search
|
||||
/// term is still a usage error. A bare separator is the way through, and it is the
|
||||
/// only way through for `comment` since the body follows in the same position.
|
||||
#[test]
|
||||
fn comment_needs_a_separator_for_a_hyphen_leading_ticket() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane, "backlog", "-leading");
|
||||
|
||||
let mut without = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
without
|
||||
.current_dir(temp.path())
|
||||
.args(["comment", "-leading", "a body"])
|
||||
.assert()
|
||||
.failure();
|
||||
|
||||
let mut with = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
with.current_dir(temp.path())
|
||||
.args(["comment", "--", "-leading", "a body"])
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
/// The one shape `allow_hyphen_values` does not reach: a lone `--` in a positional
|
||||
/// is clap's end-of-options marker, consumed before any value is assigned. So a
|
||||
/// comment body of exactly `--` needs its own separator in front of it.
|
||||
///
|
||||
/// Not a silent drop either way, which is what matters: without the separator the
|
||||
/// body is reported missing and nothing is written.
|
||||
#[test]
|
||||
fn a_bare_double_hyphen_body_needs_a_separator() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let uuid = create_ticket(&worklane, "backlog", "Bare separator");
|
||||
|
||||
let mut without = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let assert = without
|
||||
.current_dir(temp.path())
|
||||
.args(["comment", &uuid, "--"])
|
||||
.assert()
|
||||
.failure();
|
||||
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
|
||||
assert!(stderr.contains("<BODY>"), "unclear error: {stderr}");
|
||||
assert!(
|
||||
!worklane.join("comments").join(&uuid).exists(),
|
||||
"a comment was written despite the error"
|
||||
);
|
||||
|
||||
let mut with = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
with.current_dir(temp.path())
|
||||
.args(["comment", &uuid, "--", "--"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let stored: String = fs::read_dir(worklane.join("comments").join(&uuid))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| fs::read_to_string(e.path()).unwrap())
|
||||
.collect();
|
||||
assert!(stored.contains("**Comment**\n--\n"), "was {stored:?}");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
use assert_cmd::Command;
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
fn script(shell: &str) -> String {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let assert = cmd.arg("completions").arg(shell).assert().success();
|
||||
String::from_utf8(assert.get_output().stdout.clone()).unwrap()
|
||||
}
|
||||
|
||||
/// Every shell clap can generate for, since the README names all five.
|
||||
#[test]
|
||||
fn completions_prints_a_script_for_every_shell() {
|
||||
for shell in ["fish", "bash", "zsh", "elvish", "powershell"] {
|
||||
let out = script(shell);
|
||||
assert!(
|
||||
out.contains("worklane"),
|
||||
"the {shell} script never names the command"
|
||||
);
|
||||
// Long enough to be a script rather than an empty file with a comment in it.
|
||||
assert!(out.len() > 500, "the {shell} script is {} bytes", out.len());
|
||||
}
|
||||
}
|
||||
|
||||
/// No board is looked for, the way `install-skill` looks for none: the script comes off
|
||||
/// the clap definition and is the same wherever it is run. Run from a temp directory
|
||||
/// with no `.worklane` above it, which every other command refuses.
|
||||
#[test]
|
||||
fn completions_needs_no_board() {
|
||||
let temp = assert_fs::TempDir::new().unwrap();
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("completions")
|
||||
.arg("fish")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fish_gets_both_halves() {
|
||||
let out = script("fish");
|
||||
// clap's, which is where the subcommands and the flags come from.
|
||||
assert!(out.contains("__fish_worklane_needs_command"));
|
||||
assert!(out.contains("install-skill"));
|
||||
// Ours, which is where the tickets come from.
|
||||
assert!(out.contains("__worklane_first_arg_of"));
|
||||
assert!(out.contains("worklane ls --ids"));
|
||||
}
|
||||
|
||||
/// The fish half is fish syntax, so it must not reach any other shell's output.
|
||||
#[test]
|
||||
fn no_other_shell_gets_the_fish_half() {
|
||||
for shell in ["bash", "zsh", "elvish", "powershell"] {
|
||||
let out = script(shell);
|
||||
assert!(
|
||||
!out.contains("__worklane_first_arg_of"),
|
||||
"fish-only helpers leaked into {shell}"
|
||||
);
|
||||
assert!(
|
||||
!out.contains("worklane ls --ids"),
|
||||
"the dynamic half leaked into {shell}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The four statuses reach fish twice over, from clap for the `mv` option and from the
|
||||
/// appended half for the `ls` positional, which clap emits nothing for.
|
||||
#[test]
|
||||
fn fish_is_offered_every_status() {
|
||||
let out = script("fish");
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
assert!(out.contains(status), "fish is never offered {status}");
|
||||
}
|
||||
assert!(out.contains("-a 'backlog committed reviewing done' -d status"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_shell_is_a_usage_error() {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let assert = cmd.arg("completions").arg("tcsh").assert().code(2);
|
||||
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
|
||||
assert!(stderr.contains("invalid value 'tcsh'"), "{stderr}");
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
/// The documents as this test's binary carries them, so the print path is pinned to the
|
||||
/// files in the repo rather than to a description of them.
|
||||
const SKILL: &str = include_str!("../assets/SKILL.md");
|
||||
const REVIEW: &str = include_str!("../assets/REVIEW.md");
|
||||
const PLAN: &str = include_str!("../assets/PLAN.md");
|
||||
|
||||
/// `HOME` is redirected, so the suite never writes into the home of whoever runs it.
|
||||
/// A temp directory rather than the real one is also what makes the already-installed
|
||||
/// and the modified cases reachable at all.
|
||||
fn run(home: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.env("HOME", home.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn installed(home: &TempDir) -> std::path::PathBuf {
|
||||
home.path().join(".claude/skills/worklane/SKILL.md")
|
||||
}
|
||||
|
||||
fn installed_review(home: &TempDir) -> std::path::PathBuf {
|
||||
home.path().join(".claude/skills/worklane-review/SKILL.md")
|
||||
}
|
||||
|
||||
fn installed_plan(home: &TempDir) -> std::path::PathBuf {
|
||||
home.path().join(".claude/skills/worklane-plan/SKILL.md")
|
||||
}
|
||||
|
||||
/// Nothing about the skills needs a board, and they are wanted before there is one.
|
||||
///
|
||||
/// One invocation writes every document. A person who learned the command before the
|
||||
/// review skill existed gets it without learning anything new, which is the whole
|
||||
/// reason there is no name to pass.
|
||||
#[test]
|
||||
fn every_skill_installs_outside_a_worklane_directory() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
|
||||
assert!(stdout.contains(".claude/skills/worklane/SKILL.md"), "{stdout}");
|
||||
assert!(stdout.contains("Installed the worklane-review skill"), "{stdout}");
|
||||
assert!(stdout.contains(".claude/skills/worklane-review/SKILL.md"), "{stdout}");
|
||||
assert!(stdout.contains("Installed the worklane-plan skill"), "{stdout}");
|
||||
assert!(stdout.contains(".claude/skills/worklane-plan/SKILL.md"), "{stdout}");
|
||||
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
|
||||
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
||||
assert_eq!(std::fs::read_to_string(installed_plan(&home)).unwrap(), PLAN);
|
||||
|
||||
// Once, not per document: it is the one thing to do next, not part of an outcome.
|
||||
assert_eq!(
|
||||
stdout.matches("pick it up on their next session").count(),
|
||||
1,
|
||||
"{stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Narrowing to one document is the exception, and it must leave the others alone.
|
||||
#[test]
|
||||
fn a_named_skill_installs_only_that_one() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane-review"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
||||
assert!(!installed(&home).exists(), "a named install wrote the other document too");
|
||||
assert!(!installed_plan(&home).exists(), "a named install wrote the other document too");
|
||||
}
|
||||
|
||||
/// A name nothing ships is a stop, with the choices in the message: guessing at the
|
||||
/// nearest match would install a document nobody asked for.
|
||||
#[test]
|
||||
fn an_unknown_skill_name_is_refused_and_lists_what_there_is() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "reviewer"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_ne!(out.status.code(), Some(0), "{stderr}");
|
||||
assert!(stderr.contains("no skill named"), "{stderr}");
|
||||
assert!(stderr.contains("worklane-review"), "{stderr}");
|
||||
assert!(!installed(&home).exists());
|
||||
assert!(!installed_review(&home).exists());
|
||||
assert!(!installed_plan(&home).exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_second_install_says_it_is_already_up_to_date() {
|
||||
let home = TempDir::new().unwrap();
|
||||
run(&home, &["install-skill"]);
|
||||
|
||||
let out = run(&home, &["install-skill"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert!(stdout.contains("Already up to date"), "{stdout}");
|
||||
}
|
||||
|
||||
/// A copy someone edited is theirs. The command says what to do next rather than
|
||||
/// discarding it, and only `--force` overwrites.
|
||||
#[test]
|
||||
fn a_modified_copy_is_reported_and_needs_force() {
|
||||
let home = TempDir::new().unwrap();
|
||||
run(&home, &["install-skill"]);
|
||||
std::fs::write(installed(&home), "hand written\n").unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert!(stdout.contains("Differs from the version in this binary"), "{stdout}");
|
||||
assert!(stdout.contains("--force"), "{stdout}");
|
||||
assert!(stdout.contains("--print"), "the message never says how to compare: {stdout}");
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(installed(&home)).unwrap(),
|
||||
"hand written\n",
|
||||
"the modified copy was overwritten anyway"
|
||||
);
|
||||
|
||||
let out = run(&home, &["install-skill", "--force"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
|
||||
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
|
||||
}
|
||||
|
||||
/// One refused document must not stop the ones behind it: the message is per document,
|
||||
/// and the run still reports what it did with each.
|
||||
#[test]
|
||||
fn a_modified_copy_does_not_stop_the_other_documents() {
|
||||
let home = TempDir::new().unwrap();
|
||||
run(&home, &["install-skill"]);
|
||||
std::fs::write(installed(&home), "hand written\n").unwrap();
|
||||
std::fs::remove_file(installed_review(&home)).unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
||||
assert!(stdout.contains("Differs from the version in this binary"), "{stdout}");
|
||||
assert!(stdout.contains("install-skill worklane --print"), "{stdout}");
|
||||
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), "hand written\n");
|
||||
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
||||
assert_eq!(std::fs::read_to_string(installed_plan(&home)).unwrap(), PLAN);
|
||||
}
|
||||
|
||||
/// The print path is what makes a modified copy diffable, so it has to be the document
|
||||
/// byte for byte and it must not install anything on the way past.
|
||||
#[test]
|
||||
fn print_writes_the_named_document_to_stdout_and_installs_nothing() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane", "--print"]);
|
||||
assert_eq!(out.status.code(), Some(0));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout), SKILL);
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane-review", "--print"]);
|
||||
assert_eq!(out.status.code(), Some(0));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout), REVIEW);
|
||||
|
||||
let out = run(&home, &["install-skill", "worklane-plan", "--print"]);
|
||||
assert_eq!(out.status.code(), Some(0));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout), PLAN);
|
||||
|
||||
assert!(!installed(&home).exists(), "--print installed the skill anyway");
|
||||
assert!(!installed_review(&home).exists(), "--print installed the skill anyway");
|
||||
assert!(!installed_plan(&home).exists(), "--print installed the skill anyway");
|
||||
}
|
||||
|
||||
/// A diff is against one document. Printing them all run together would be neither of
|
||||
/// them, so an unnamed `--print` says what to type instead of guessing.
|
||||
#[test]
|
||||
fn print_without_a_name_says_which_names_there_are() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&home, &["install-skill", "--print"]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_ne!(out.status.code(), Some(0), "{stderr}");
|
||||
assert!(stderr.contains("name the skill to print"), "{stderr}");
|
||||
assert!(stderr.contains("worklane-review"), "{stderr}");
|
||||
assert!(String::from_utf8_lossy(&out.stdout).is_empty(), "a document was printed anyway");
|
||||
}
|
||||
|
||||
/// The command has to be findable by someone who does not already know it exists.
|
||||
#[test]
|
||||
fn the_help_lists_the_install_skill_command() {
|
||||
let home = TempDir::new().unwrap();
|
||||
|
||||
let stdout = String::from_utf8_lossy(&run(&home, &["--help"]).stdout).to_string();
|
||||
assert!(stdout.contains("install-skill"), "{stdout}");
|
||||
}
|
||||
+411
-14
@@ -17,7 +17,7 @@ fn setup_worklane(temp: &TempDir) -> std::path::PathBuf {
|
||||
}
|
||||
|
||||
fn create_ticket(
|
||||
worklane_dir: &std::path::PathBuf,
|
||||
worklane_dir: &std::path::Path,
|
||||
status: &str,
|
||||
title: &str,
|
||||
owner: &str,
|
||||
@@ -71,7 +71,7 @@ fn ls_without_status_shows_overview() {
|
||||
create_ticket(&worklane, "done", "Feature D", "dave", "2026-09-01");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("ls").assert().success();
|
||||
cmd.current_dir(temp.path()).arg("ls").assert().success();
|
||||
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("BACKLOG"));
|
||||
@@ -94,7 +94,7 @@ fn ls_with_status_filters_tickets() {
|
||||
create_ticket(&worklane, "reviewing", "Feature C", "charlie", "2026-08-01");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("ls").args(["committed"]);
|
||||
cmd.current_dir(temp.path()).arg("ls").args(["committed"]);
|
||||
|
||||
cmd.assert().success();
|
||||
|
||||
@@ -107,7 +107,7 @@ fn ls_with_invalid_status_fails() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("ls")
|
||||
.args(["nonexistent"])
|
||||
.assert()
|
||||
@@ -124,7 +124,7 @@ fn ls_listed_tickets_sorted_alphabetically() {
|
||||
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-08-01");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("ls")
|
||||
.args(["backlog"])
|
||||
.assert()
|
||||
@@ -146,7 +146,7 @@ fn ls_empty_status_shows_message() {
|
||||
|
||||
// Intentionally leave "done" empty
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("ls")
|
||||
.args(["done"])
|
||||
.assert()
|
||||
@@ -164,7 +164,7 @@ fn ls_displays_owner_and_due() {
|
||||
create_ticket(&worklane, "backlog", "Test ticket", "alice", "2026-12-31");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("ls")
|
||||
.args(["backlog"])
|
||||
.assert()
|
||||
@@ -191,7 +191,7 @@ fn ls_handles_short_and_non_ascii_filenames() {
|
||||
}
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("ls").arg("backlog").assert().success();
|
||||
cmd.current_dir(temp.path()).arg("ls").arg("backlog").assert().success();
|
||||
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert_eq!(stdout.matches("Odd Name").count(), 3);
|
||||
@@ -209,7 +209,7 @@ fn ls_survives_a_malformed_created_at() {
|
||||
.unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("ls").arg("backlog").assert().success();
|
||||
cmd.current_dir(temp.path()).arg("ls").arg("backlog").assert().success();
|
||||
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Bad Date"));
|
||||
@@ -217,7 +217,7 @@ fn ls_survives_a_malformed_created_at() {
|
||||
assert!(!stdout.contains("日本語"));
|
||||
}
|
||||
|
||||
fn create_ticket_with_priority(worklane_dir: &std::path::PathBuf, title: &str, priority: &str) {
|
||||
fn create_ticket_with_priority(worklane_dir: &std::path::Path, title: &str, priority: &str) {
|
||||
let slug: String = title.to_lowercase().replace(' ', "-");
|
||||
let body = format!(
|
||||
"# {}\n\n## Metadata\n\n- **ID**: 00000000-0000-0000-0000-00000000000{}\n\
|
||||
@@ -242,7 +242,7 @@ fn ls_sorts_by_priority_then_title() {
|
||||
create_ticket(&worklane, "backlog", "No priority at all", "alice", "_Not set_");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("ls").arg("backlog");
|
||||
cmd.current_dir(temp.path()).arg("ls").arg("backlog");
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
let at = |needle: &str| stdout.find(needle).unwrap_or_else(|| panic!("{needle} missing"));
|
||||
@@ -261,7 +261,7 @@ fn ls_filters_by_priority_and_composes_with_status() {
|
||||
create_ticket_with_priority(&worklane, "Lower one", "3");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--priority", "1"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Urgent one"));
|
||||
@@ -269,7 +269,7 @@ fn ls_filters_by_priority_and_composes_with_status() {
|
||||
|
||||
// Same filter without a status, through the grouped listing
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).args(["ls", "--priority", "3"]);
|
||||
cmd.current_dir(temp.path()).args(["ls", "--priority", "3"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Lower one"));
|
||||
assert!(!stdout.contains("Urgent one"));
|
||||
@@ -285,7 +285,7 @@ fn ls_shows_a_mark_for_the_level() {
|
||||
create_ticket(&worklane, "backlog", "Nothing set", "alice", "_Not set_");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("ls").arg("backlog");
|
||||
cmd.current_dir(temp.path()).arg("ls").arg("backlog");
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
// Piped, so no escapes: the glyph is carrying the level by itself
|
||||
@@ -296,3 +296,400 @@ fn ls_shows_a_mark_for_the_level() {
|
||||
// The raw number is not what the listing shows
|
||||
assert!(!stdout.contains(" 1 "), "the digit leaked into the row");
|
||||
}
|
||||
|
||||
/// A ticket whose Tags field is whatever the test needs it to be, written verbatim so a
|
||||
/// missing field, an unset one and a real list are all reachable.
|
||||
fn create_ticket_with_tags(
|
||||
worklane_dir: &std::path::Path,
|
||||
status: &str,
|
||||
title: &str,
|
||||
tags: &str,
|
||||
priority: &str,
|
||||
) {
|
||||
let slug: String = title.to_lowercase().replace(' ', "-");
|
||||
let body = format!(
|
||||
"# {title}\n\n## Metadata\n\n - **ID**: 00000000-0000-0000-0000-000000000001\n - **Priority**: {priority}\n{tags} - **Due**: _Not set_\n- **Owner**: alice\n- **Status**: {status}\n"
|
||||
);
|
||||
fs::write(
|
||||
worklane_dir
|
||||
.join(status)
|
||||
.join(format!("00000000-0000-0000-0000-000000000001_{slug}.md")),
|
||||
body,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// The Tags line as a ticket carries it, for the common case of a real list.
|
||||
fn tags(list: &str) -> String {
|
||||
format!("- **Tags**: {list}\n")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ls_filters_by_tag_and_composes_with_status_and_priority() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug,cli"), "1");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Tagged feature", &tags("feature"), "1");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Lower bug", &tags("bug"), "3");
|
||||
create_ticket_with_tags(&worklane, "committed", "Started bug", &tags("bug"), "1");
|
||||
|
||||
// Alone, through the grouped listing: every status, only the tagged tickets.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"), "{stdout}");
|
||||
assert!(stdout.contains("Lower bug"), "{stdout}");
|
||||
assert!(stdout.contains("Started bug"), "a tagged ticket in another status was dropped");
|
||||
assert!(!stdout.contains("Tagged feature"), "an untagged ticket came through");
|
||||
// The counts are filtered too, since they are the same collect.
|
||||
assert!(stdout.contains("[BACKLOG] 2 tickets"), "{stdout}");
|
||||
assert!(stdout.contains("[COMMITTED] 1 ticket"), "{stdout}");
|
||||
|
||||
// With the status positional.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"));
|
||||
assert!(stdout.contains("Lower bug"));
|
||||
assert!(!stdout.contains("Started bug"), "the status was ignored");
|
||||
|
||||
// With --priority, and with both: none asked for is everything kept, so the three
|
||||
// compose without a rule per pair.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "--tag", "bug", "--priority", "1"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"));
|
||||
assert!(stdout.contains("Started bug"));
|
||||
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug", "--priority", "1"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Tagged bug"));
|
||||
assert!(!stdout.contains("Lower bug"), "the priority was ignored");
|
||||
assert!(!stdout.contains("Started bug"), "the status was ignored");
|
||||
assert!(!stdout.contains("Tagged feature"), "the tag was ignored");
|
||||
}
|
||||
|
||||
/// The field is a list of whole values, not a string to search: a ticket tagged `bugfix`
|
||||
/// is not a ticket tagged `bug`, and neither is one tagged `Bug`. Case sensitive is the
|
||||
/// opinion the field already takes, since `tag_color` draws those two differently.
|
||||
#[test]
|
||||
fn ls_matches_a_whole_tag_value_and_not_a_substring_or_another_case() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Real bug", &tags("bug"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Only bugfix", &tags("bugfix"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Capital Bug", &tags("Bug"), "2");
|
||||
// A value that only appears with its neighbours around it, so a match on the raw
|
||||
// field would find it and a match on the split values cannot.
|
||||
create_ticket_with_tags(&worklane, "backlog", "Spaced list", &tags("cli, filter"), "2");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Real bug"), "{stdout}");
|
||||
assert!(!stdout.contains("Only bugfix"), "bug matched bugfix");
|
||||
assert!(!stdout.contains("Capital Bug"), "bug matched Bug");
|
||||
|
||||
// Trimmed on the way in, so the space after the comma is not part of the tag.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "filter"]);
|
||||
assert!(get_stdout(&mut cmd).contains("Spaced list"));
|
||||
|
||||
// And the field as written is not itself a tag.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "cli, filter"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(!stdout.contains("Spaced list"), "the whole field matched as one tag");
|
||||
}
|
||||
|
||||
/// No tags is no match, however the ticket spells it: the field absent, unset, or empty.
|
||||
#[test]
|
||||
fn ls_never_matches_a_ticket_carrying_no_tags() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Has one", &tags("bug"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Field unset", &tags("_None_"), "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Field empty", "- **Tags**:\n", "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Field missing", "", "2");
|
||||
create_ticket_with_tags(&worklane, "backlog", "Only commas", &tags(", ,"), "2");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "bug"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Has one"), "{stdout}");
|
||||
for absent in ["Field unset", "Field empty", "Field missing", "Only commas"] {
|
||||
assert!(!stdout.contains(absent), "{absent} matched a tag it does not carry");
|
||||
}
|
||||
|
||||
// Nor does an empty tag reach the filter: the value parser refuses it, so nothing is
|
||||
// listed rather than everything.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", ""]);
|
||||
cmd.assert().failure().code(2);
|
||||
}
|
||||
|
||||
/// A tag nothing carries lists nothing and still succeeds. The message is the one `ls`
|
||||
/// already gives for a filter that empties a status, rather than a second one invented
|
||||
/// here for tags alone.
|
||||
#[test]
|
||||
fn ls_with_a_tag_nothing_carries_lists_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_tags(&worklane, "backlog", "Tagged bug", &tags("bug"), "2");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "frontend"]);
|
||||
cmd.assert().success();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "backlog", "--tag", "frontend"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(!stdout.contains("Tagged bug"), "{stdout}");
|
||||
assert!(stdout.contains("No tickets in 'backlog' status."), "{stdout}");
|
||||
|
||||
// Through the grouped listing the counts go to zero and no section is drawn.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--tag", "frontend"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("[BACKLOG] 0 tickets"), "{stdout}");
|
||||
assert!(!stdout.contains("Tagged bug"), "{stdout}");
|
||||
}
|
||||
|
||||
/// A ticket with an id of its own, since `create_ticket` gives every fixture the same
|
||||
/// uuid and `--ids` is the one output where the id is the whole point.
|
||||
fn create_ticket_with_id(
|
||||
worklane_dir: &std::path::Path,
|
||||
status: &str,
|
||||
title: &str,
|
||||
uuid: &str,
|
||||
tags: &str,
|
||||
) {
|
||||
let ticket_body = format!(
|
||||
"# {title}\n\n## Metadata\n\n- **ID**: {uuid}\n- **Tags**: {tags}\n- **Owner**: alice\n- **Status**: {status}\n"
|
||||
);
|
||||
let filename = format!("{uuid}_{}.md", slug(title));
|
||||
fs::write(worklane_dir.join(status).join(filename), ticket_body).unwrap();
|
||||
}
|
||||
|
||||
/// The slug rule, as AGENTS.md requires: derived, never written by hand.
|
||||
fn slug(title: &str) -> String {
|
||||
title
|
||||
.to_lowercase()
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric() || *c == ' ' || *c == '-' || *c == '_')
|
||||
.map(|c| if c == ' ' { '-' } else { c })
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// One ticket per line, the seven-character id then a tab then the title, and nothing
|
||||
/// else: no heading, no counts, no owner or due column.
|
||||
#[test]
|
||||
fn ls_ids_prints_the_id_and_the_title_and_nothing_else() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_id(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Feature A",
|
||||
"1b78a24c-0000-0000-0000-000000000001",
|
||||
"bug",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--ids"]);
|
||||
cmd.assert().success();
|
||||
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert_eq!(stdout, "1b78a24\tFeature A\n", "{stdout:?}");
|
||||
}
|
||||
|
||||
/// Every status, done included, where the decorated listing leaves done out. A
|
||||
/// completion has to be able to name a finished ticket.
|
||||
#[test]
|
||||
fn ls_ids_includes_done_and_narrows_to_a_named_status() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_id(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Still open",
|
||||
"aaaaaaa1-0000-0000-0000-000000000001",
|
||||
"bug",
|
||||
);
|
||||
create_ticket_with_id(
|
||||
&worklane,
|
||||
"done",
|
||||
"Finished",
|
||||
"bbbbbbb2-0000-0000-0000-000000000002",
|
||||
"bug",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--ids"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(stdout.contains("Still open"), "{stdout}");
|
||||
assert!(stdout.contains("Finished"), "a done ticket cannot be named: {stdout}");
|
||||
|
||||
// The decorated listing is unchanged: done is counted, not listed.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).arg("ls");
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert!(!stdout.contains("Finished"), "{stdout}");
|
||||
|
||||
// The positional still narrows it.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "done", "--ids"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert_eq!(stdout, "bbbbbbb\tFinished\n", "{stdout:?}");
|
||||
}
|
||||
|
||||
/// The filters apply to `--ids` exactly as they do to the listing, so a completion can
|
||||
/// be narrowed the same way.
|
||||
#[test]
|
||||
fn ls_ids_still_takes_the_filters() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_id(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Tagged bug",
|
||||
"aaaaaaa1-0000-0000-0000-000000000001",
|
||||
"bug",
|
||||
);
|
||||
create_ticket_with_id(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Tagged cli",
|
||||
"bbbbbbb2-0000-0000-0000-000000000002",
|
||||
"cli",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--ids", "--tag", "cli"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert_eq!(stdout, "bbbbbbb\tTagged cli\n", "{stdout:?}");
|
||||
}
|
||||
|
||||
/// An unknown campaign is refused before anything is read, even here. A completion that
|
||||
/// listed the whole board because the name was misspelled would be worse than one that
|
||||
/// printed nothing.
|
||||
#[test]
|
||||
fn ls_ids_still_refuses_an_unknown_campaign() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket_with_id(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Feature A",
|
||||
"aaaaaaa1-0000-0000-0000-000000000001",
|
||||
"bug",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["ls", "--ids", "--campaign", "no such campaign"]);
|
||||
cmd.assert().failure();
|
||||
}
|
||||
|
||||
/// A status the board is missing is skipped rather than refused, unlike the listing:
|
||||
/// the caller is a shell filling in candidates, and an error printed over the prompt is
|
||||
/// worse there than no candidates.
|
||||
#[test]
|
||||
fn ls_ids_is_quiet_about_a_missing_status_directory() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
worklane.child("backlog").create_dir_all().unwrap();
|
||||
|
||||
create_ticket_with_id(
|
||||
worklane.path(),
|
||||
"backlog",
|
||||
"Feature A",
|
||||
"aaaaaaa1-0000-0000-0000-000000000001",
|
||||
"bug",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "--ids"]);
|
||||
cmd.assert().success();
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
assert_eq!(stdout, "aaaaaaa\tFeature A\n", "{stdout:?}");
|
||||
|
||||
// The listing still says so, since a person reading it can act on it.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "done"]);
|
||||
let assert = cmd.assert().failure();
|
||||
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
|
||||
assert!(stderr.contains("No 'done' directory"), "{stderr}");
|
||||
}
|
||||
|
||||
/// A status outside the four is clap's to refuse now, so it is a usage error naming the
|
||||
/// four rather than a runtime one.
|
||||
#[test]
|
||||
fn ls_names_the_four_statuses_when_given_another() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let assert = cmd
|
||||
.current_dir(temp.path())
|
||||
.args(["ls", "nonexistent"])
|
||||
.assert()
|
||||
.code(2);
|
||||
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
|
||||
assert!(stderr.contains("invalid value 'nonexistent'"), "{stderr}");
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
assert!(stderr.contains(status), "{status} is not offered: {stderr}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The listing reads the fields it prints and nothing else, so the stamps `mv` writes
|
||||
/// do not reach it. Pinned against a ticket carrying one, since a listing that started
|
||||
/// showing them would change the output every board and completion script parses.
|
||||
#[test]
|
||||
fn ls_output_is_unchanged_by_a_status_stamp() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket(&worklane, "committed", "Stamped", "alice", "2026-06-01");
|
||||
let path = worklane
|
||||
.join("committed")
|
||||
.join("00000000-0000-0000-0000-000000000001_stamped.md");
|
||||
let before = {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).arg("ls").arg("committed");
|
||||
get_stdout(&mut cmd)
|
||||
};
|
||||
|
||||
let stamped = fs::read_to_string(&path)
|
||||
.unwrap()
|
||||
.replace("- **Status**:", "- **Committed On**: 2026-08-22 09:14:30\n- **Status**:");
|
||||
fs::write(&path, stamped).unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).arg("ls").arg("committed");
|
||||
let after = get_stdout(&mut cmd);
|
||||
|
||||
assert_eq!(after, before);
|
||||
assert!(!after.contains("Committed On"), "{after}");
|
||||
}
|
||||
|
||||
+643
-16
@@ -2,7 +2,7 @@ use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
@@ -17,8 +17,13 @@ fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
/// Every metadata field a ticket has, positionally. The lint is right that the call
|
||||
/// site reads as a wall of strings, and the fix is a struct with named fields, but
|
||||
/// that is a change to thirteen call sites in this file alone and belongs in its own
|
||||
/// commit rather than in a warning sweep.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn create_ticket(
|
||||
worklane_dir: &PathBuf,
|
||||
worklane_dir: &Path,
|
||||
status: &str,
|
||||
title: &str,
|
||||
description: &str,
|
||||
@@ -89,7 +94,7 @@ fn mv_forwards_from_backlog_to_committed() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -133,7 +138,7 @@ fn mv_blocks_backward_move() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -163,7 +168,7 @@ fn mv_allows_backward_move_with_force() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -197,7 +202,7 @@ fn mv_blocks_nonsequential_forward_move() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -227,7 +232,7 @@ fn mv_allows_skipping_stages_with_force() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -259,7 +264,7 @@ fn mv_ignores_already_in_same_status() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -272,13 +277,16 @@ fn mv_ignores_already_in_same_status() {
|
||||
assert!(worklane.join("reviewing").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// A status is a value enum, so an unknown one is clap's to refuse: exit 2, the four
|
||||
/// named, and the ticket untouched. The same bargain `--due` and `--priority` take, and
|
||||
/// the reason `cmd_mv` no longer checks.
|
||||
#[test]
|
||||
fn mv_rejects_invalid_status() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let id = "abc123def456789012345678901234567890";
|
||||
let _filename = create_ticket(
|
||||
let filename = create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Invalid Target",
|
||||
@@ -290,16 +298,23 @@ fn mv_rejects_invalid_status() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
.arg("invalid")
|
||||
.assert()
|
||||
.failure();
|
||||
.code(2);
|
||||
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Invalid target status"));
|
||||
assert!(stderr.contains("invalid value 'invalid'"), "{stderr}");
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
assert!(stderr.contains(status), "{status} is not offered: {stderr}");
|
||||
}
|
||||
assert!(
|
||||
worklane.join("backlog").join(&filename).exists(),
|
||||
"the ticket moved anyway"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -320,7 +335,7 @@ fn mv_uses_ticket_id_for_resolution() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -354,7 +369,7 @@ fn mv_keeps_status_in_sync_across_consecutive_moves() {
|
||||
for target in ["committed", "reviewing"] {
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(&temp.path())
|
||||
.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -392,7 +407,7 @@ fn mv_repairs_legacy_status_field() {
|
||||
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(&temp.path())
|
||||
.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -415,7 +430,7 @@ fn mv_fails_when_status_field_is_missing() {
|
||||
fs::write(&path, "# No Status\n\n## Metadata\n\n- **Owner**: jack\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("mv")
|
||||
.arg("abc123def4567")
|
||||
.arg("--status")
|
||||
@@ -431,3 +446,615 @@ fn mv_fails_when_status_field_is_missing() {
|
||||
assert!(worklane.join("backlog").join(filename).exists());
|
||||
assert!(!worklane.join("committed").join(filename).exists());
|
||||
}
|
||||
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
fn chmod(path: &std::path::Path, mode: u32) {
|
||||
let mut perms = fs::metadata(path).unwrap().permissions();
|
||||
perms.set_mode(mode);
|
||||
fs::set_permissions(path, perms).unwrap();
|
||||
}
|
||||
|
||||
fn md_files(dir: &std::path::Path) -> Vec<String> {
|
||||
match fs::read_dir(dir) {
|
||||
Ok(entries) => entries
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.filter(|name| name.ends_with(".md"))
|
||||
.collect(),
|
||||
Err(_) => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
/// Nothing is staged in a status directory, so nothing can be left behind that the
|
||||
/// listing would read as a ticket.
|
||||
fn stray_files(worklane: &std::path::Path) -> Vec<String> {
|
||||
let mut stray: Vec<String> = fs::read_dir(worklane)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.filter(|name| !["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str()))
|
||||
.collect();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
stray.extend(
|
||||
fs::read_dir(worklane.join(dir))
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.filter(|name| !name.ends_with(".md")),
|
||||
);
|
||||
}
|
||||
|
||||
stray
|
||||
}
|
||||
|
||||
/// The bug this fixes. The old order renamed first and wrote second, so a write
|
||||
/// that failed left the ticket in its new directory still claiming the old status.
|
||||
/// A read-only ticket file is the cheapest way to make the write fail.
|
||||
#[test]
|
||||
fn mv_never_leaves_stale_content_in_the_target_directory() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let filename = create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Read Only",
|
||||
"A description.",
|
||||
"abc123def456789012345678901234567890",
|
||||
"alice",
|
||||
"2026-12-31",
|
||||
"test",
|
||||
);
|
||||
|
||||
let source = worklane.join("backlog").join(&filename);
|
||||
chmod(&source, 0o444);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["mv", "abc123def4567", "--status", "committed"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
// Wherever it ended up, its Status must agree with the directory it is in
|
||||
let moved = worklane.join("committed").join(&filename);
|
||||
assert!(moved.exists(), "ticket did not move");
|
||||
let content = fs::read_to_string(&moved).unwrap();
|
||||
assert!(
|
||||
content.contains("- **Status**: committed"),
|
||||
"stale status: {content:?}"
|
||||
);
|
||||
assert!(!content.contains("- **Status**: backlog"), "{content:?}");
|
||||
|
||||
assert_eq!(md_files(&worklane.join("backlog")).len(), 0);
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// The other criterion: one directory or the other, never both. An unwritable
|
||||
/// target directory fails the move at the last step, which is the step that would
|
||||
/// have to be reordered to break this.
|
||||
#[test]
|
||||
fn mv_leaves_the_ticket_in_one_place_when_the_move_fails() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let filename = create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Blocked Move",
|
||||
"A description.",
|
||||
"abc123def456789012345678901234567890",
|
||||
"alice",
|
||||
"2026-12-31",
|
||||
"test",
|
||||
);
|
||||
|
||||
let target = worklane.join("committed");
|
||||
chmod(&target, 0o555);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let assert = cmd
|
||||
.current_dir(temp.path())
|
||||
.args(["mv", "abc123def4567", "--status", "committed"])
|
||||
.assert()
|
||||
.failure();
|
||||
|
||||
let stderr = String::from_utf8(assert.get_output().stderr.clone()).unwrap();
|
||||
// Named, not a bare io error
|
||||
assert!(stderr.contains("Blocked Move"), "{stderr}");
|
||||
|
||||
assert_eq!(
|
||||
md_files(&worklane.join("backlog")),
|
||||
vec![filename.clone()],
|
||||
"the ticket left its own directory"
|
||||
);
|
||||
assert_eq!(md_files(&target).len(), 0, "the ticket is in both places");
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
|
||||
// The documented worst case: still in its old directory, carrying a Status one
|
||||
// move ahead because the content was written before the move was attempted.
|
||||
let left = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
|
||||
assert!(left.contains("- **Status**: committed"), "{left:?}");
|
||||
|
||||
// And the state is recoverable, because the directory is what decides the
|
||||
// current status, so a retry moves it rather than refusing.
|
||||
chmod(&target, 0o755);
|
||||
|
||||
let mut retry = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
retry
|
||||
.current_dir(temp.path())
|
||||
.args(["mv", "abc123def4567", "--status", "committed"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
assert_eq!(md_files(&target), vec![filename]);
|
||||
assert_eq!(md_files(&worklane.join("backlog")).len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mv_leaves_nothing_behind_on_success() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Clean Move",
|
||||
"A description.",
|
||||
"abc123def456789012345678901234567890",
|
||||
"alice",
|
||||
"2026-12-31",
|
||||
"test",
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["mv", "abc123def4567", "--status", "committed"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// Duplicate titles are allowed, so the file cannot be located by title. It used to be,
|
||||
/// and `mv <uuid-of-second>` moved the first ticket that shared its title.
|
||||
#[test]
|
||||
fn mv_moves_the_resolved_ticket_when_two_share_a_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
for uuid in [
|
||||
"11111111-aaaa-bbbb-cccc-dddddddddddd",
|
||||
"22222222-aaaa-bbbb-cccc-dddddddddddd",
|
||||
] {
|
||||
fs::write(
|
||||
worklane.join("backlog").join(format!("{}_foo.md", uuid)),
|
||||
format!(
|
||||
"# Foo\n\n## Metadata\n\n- **ID**: {}\n- **Status**: backlog\n",
|
||||
uuid
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["mv", "22222222", "--status", "committed"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
assert_eq!(
|
||||
md_files(&worklane.join("committed")),
|
||||
vec!["22222222-aaaa-bbbb-cccc-dddddddddddd_foo.md".to_string()],
|
||||
"the wrong ticket moved"
|
||||
);
|
||||
assert_eq!(
|
||||
md_files(&worklane.join("backlog")),
|
||||
vec!["11111111-aaaa-bbbb-cccc-dddddddddddd_foo.md".to_string()]
|
||||
);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------- blocked by --
|
||||
|
||||
/// A ticket waiting on another, and a second one for it to wait on. Returns the
|
||||
/// filename of the gated ticket, whose relations the moves are then checked against.
|
||||
fn create_gated_pair(worklane: &std::path::Path, temp: &TempDir, status: &str) -> String {
|
||||
let filename = create_ticket(
|
||||
worklane,
|
||||
status,
|
||||
"Gated Task",
|
||||
"Waits on the blocker.",
|
||||
"aaaa1111aaaa1111aaaa1111aaaa1111aaaa",
|
||||
"alice",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
create_ticket(
|
||||
worklane,
|
||||
"backlog",
|
||||
"The Blocker",
|
||||
"Nothing waits on this.",
|
||||
"bbbb2222bbbb2222bbbb2222bbbb2222bbbb",
|
||||
"bob",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
|
||||
// Through the command, so the fixture cannot store a relation in a shape the tool
|
||||
// does not actually write.
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(temp.path())
|
||||
.args(["relate", "aaaa1111", "--blocked-by", "bbbb2222"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
filename
|
||||
}
|
||||
|
||||
fn move_ticket(temp: &TempDir, ticket: &str, status: &str, force: bool) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["mv", ticket, "--status", status]);
|
||||
if force {
|
||||
cmd.arg("-f");
|
||||
}
|
||||
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
/// Refused, and nothing written: not the rename, not the Status field, not a stray
|
||||
/// temp file. The blocker is named with its status, since that is what has to change.
|
||||
#[test]
|
||||
fn mv_refuses_a_move_while_a_blocker_is_open() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
let before = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(!out.status.success());
|
||||
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(stderr.contains("blocked by"), "{stderr}");
|
||||
assert!(stderr.contains("The Blocker"), "{stderr}");
|
||||
assert!(stderr.contains("backlog"), "{stderr}");
|
||||
assert!(stderr.contains("--force"), "{stderr}");
|
||||
|
||||
assert!(worklane.join("backlog").join(&filename).exists());
|
||||
assert_eq!(md_files(&worklane.join("committed")).len(), 0);
|
||||
assert_eq!(
|
||||
fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap(),
|
||||
before,
|
||||
"a refused move rewrote the ticket"
|
||||
);
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
/// Every open blocker, not the first: clearing the one the message happened to name
|
||||
/// would leave the ticket blocked and the reader surprised.
|
||||
#[test]
|
||||
fn mv_names_every_open_blocker() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_gated_pair(&worklane, &temp, "backlog");
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"reviewing",
|
||||
"The Second Blocker",
|
||||
"Also not done.",
|
||||
"cccc3333cccc3333cccc3333cccc3333cccc",
|
||||
"bob",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(temp.path())
|
||||
.args(["relate", "aaaa1111", "--blocked-by", "cccc3333"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(stderr.contains("The Blocker"), "{stderr}");
|
||||
assert!(stderr.contains("The Second Blocker"), "{stderr}");
|
||||
}
|
||||
|
||||
/// `-f` is where the deliberate overrides live, beside the backward and skipping moves.
|
||||
#[test]
|
||||
fn mv_moves_a_blocked_ticket_with_force() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", true);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mv_allows_the_move_once_the_blocker_is_done() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
|
||||
for status in ["committed", "reviewing", "done"] {
|
||||
assert!(
|
||||
move_ticket(&temp, "bbbb2222", status, false).status.success(),
|
||||
"the blocker itself could not be moved to {status}"
|
||||
);
|
||||
}
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// Every move, not only the one into committed. An open blocker is a reason not to
|
||||
/// finish as much as a reason not to start.
|
||||
#[test]
|
||||
fn mv_checks_the_blockers_on_every_move() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "reviewing");
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "done", false);
|
||||
assert!(!out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("reviewing").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// A move to the status the ticket is already in is not a move, so it is reported the
|
||||
/// way it always was rather than refused.
|
||||
#[test]
|
||||
fn mv_does_not_check_the_blockers_on_a_no_op() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_gated_pair(&worklane, &temp, "backlog");
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "backlog", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(String::from_utf8_lossy(&out.stdout).contains("already in"));
|
||||
}
|
||||
|
||||
/// A dangling target is a bookkeeping fault, not a dependency. Refusing there would
|
||||
/// wedge the ticket with no way out but `--force`.
|
||||
#[test]
|
||||
fn mv_warns_and_allows_when_a_blocker_is_not_on_the_board() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_gated_pair(&worklane, &temp, "backlog");
|
||||
fs::remove_file(
|
||||
worklane
|
||||
.join("backlog")
|
||||
.join("bbbb2222bbbb2222bbbb2222bbbb2222bbbb_the-blocker.md"),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("not on the board"),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// Only `blocked by` gates a move. The other two kinds are reference data.
|
||||
#[test]
|
||||
fn mv_ignores_the_kinds_that_are_not_blockers() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"Related Task",
|
||||
"Points at an open ticket.",
|
||||
"aaaa1111aaaa1111aaaa1111aaaa1111aaaa",
|
||||
"alice",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
create_ticket(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"The Other",
|
||||
"Still open.",
|
||||
"bbbb2222bbbb2222bbbb2222bbbb2222bbbb",
|
||||
"bob",
|
||||
"_Not set_",
|
||||
"test",
|
||||
);
|
||||
|
||||
Command::cargo_bin(BIN_NAME)
|
||||
.unwrap()
|
||||
.current_dir(temp.path())
|
||||
.args([
|
||||
"relate",
|
||||
"aaaa1111",
|
||||
"--regression-of",
|
||||
"bbbb2222",
|
||||
"--relates-to",
|
||||
"bbbb2222",
|
||||
])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(worklane.join("committed").join(&filename).exists());
|
||||
}
|
||||
|
||||
/// The value of a metadata field, or nothing when the ticket does not carry it.
|
||||
fn field(content: &str, name: &str) -> Option<String> {
|
||||
let prefix = format!("- **{}**: ", name);
|
||||
content
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix(prefix.as_str()))
|
||||
.map(str::to_string)
|
||||
}
|
||||
|
||||
/// `%Y-%m-%d %H:%M:%S`, checked by shape. A test cannot pin the clock, so what it can
|
||||
/// assert is that the stamp carries the same format `Created At` does.
|
||||
fn is_timestamp(value: &str) -> bool {
|
||||
value.len() == 19
|
||||
&& value.chars().enumerate().all(|(index, c)| match index {
|
||||
4 | 7 => c == '-',
|
||||
10 => c == ' ',
|
||||
13 | 16 => c == ':',
|
||||
_ => c.is_ascii_digit(),
|
||||
})
|
||||
}
|
||||
|
||||
fn stamped_ticket(worklane: &Path, status: &str) -> String {
|
||||
create_ticket(
|
||||
worklane,
|
||||
status,
|
||||
"Stamped Task",
|
||||
"Carries the stamps.",
|
||||
"cccc3333cccc3333cccc3333cccc3333cccc",
|
||||
"alice",
|
||||
"_Not set_",
|
||||
"test",
|
||||
)
|
||||
}
|
||||
|
||||
fn ticket_at(worklane: &Path, status: &str, filename: &str) -> String {
|
||||
fs::read_to_string(worklane.join(status).join(filename)).unwrap()
|
||||
}
|
||||
|
||||
/// One field per status, written with the time of the move, and only the current one:
|
||||
/// the stamps are where the ticket is now, not the trail of how it got there.
|
||||
#[test]
|
||||
fn mv_stamps_the_field_of_the_status_it_enters() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "backlog");
|
||||
|
||||
for (status, stamp, cleared) in [
|
||||
("committed", "Committed On", "Submitted On"),
|
||||
("reviewing", "Submitted On", "Committed On"),
|
||||
("done", "Completed On", "Submitted On"),
|
||||
] {
|
||||
let out = move_ticket(&temp, "cccc3333", status, false);
|
||||
assert!(out.status.success(), "{:?}", out);
|
||||
|
||||
let content = ticket_at(&worklane, status, &filename);
|
||||
let value = field(&content, stamp)
|
||||
.unwrap_or_else(|| panic!("no {stamp} after moving to {status}: {content}"));
|
||||
|
||||
assert!(is_timestamp(&value), "{stamp} reads '{value}'");
|
||||
assert_eq!(field(&content, cleared), None, "{content}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Backlog has no stamp of its own, so a ticket forced back to it carries none at all
|
||||
/// rather than a Completed On for work that has been undone.
|
||||
#[test]
|
||||
fn mv_removes_the_stamp_of_the_status_it_leaves() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "backlog");
|
||||
|
||||
move_ticket(&temp, "cccc3333", "done", true);
|
||||
let done = ticket_at(&worklane, "done", &filename);
|
||||
assert!(field(&done, "Completed On").is_some(), "{done}");
|
||||
|
||||
move_ticket(&temp, "cccc3333", "backlog", true);
|
||||
|
||||
let content = ticket_at(&worklane, "backlog", &filename);
|
||||
for stamp in ["Committed On", "Submitted On", "Completed On"] {
|
||||
assert_eq!(field(&content, stamp), None, "{content}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Re-entry is the time of the move that brought the ticket back, not the first one.
|
||||
#[test]
|
||||
fn mv_restamps_a_status_the_ticket_is_re_entering() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "committed");
|
||||
|
||||
// Hand-written so the earlier value is old enough to tell from the move's own time,
|
||||
// which two moves in the same second would not be.
|
||||
let path = worklane.join("committed").join(&filename);
|
||||
let seeded = fs::read_to_string(&path)
|
||||
.unwrap()
|
||||
.replace("- **Status**:", "- **Committed On**: 2020-01-01 00:00:00\n- **Status**:");
|
||||
fs::write(&path, seeded).unwrap();
|
||||
|
||||
move_ticket(&temp, "cccc3333", "backlog", true);
|
||||
move_ticket(&temp, "cccc3333", "committed", false);
|
||||
|
||||
let content = ticket_at(&worklane, "committed", &filename);
|
||||
let value = field(&content, "Committed On").expect(&content);
|
||||
|
||||
assert!(is_timestamp(&value), "{value}");
|
||||
assert_ne!(value, "2020-01-01 00:00:00");
|
||||
assert_eq!(content.matches("**Committed On**:").count(), 1, "{content}");
|
||||
}
|
||||
|
||||
/// The fixture predates the fields, as every ticket on a real board does, so the line
|
||||
/// is inserted rather than rewritten. Against METADATA_ORDER, which keeps Status last.
|
||||
#[test]
|
||||
fn mv_inserts_the_stamp_before_the_status_field() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "backlog");
|
||||
|
||||
move_ticket(&temp, "cccc3333", "committed", false);
|
||||
|
||||
let content = ticket_at(&worklane, "committed", &filename);
|
||||
let value = field(&content, "Committed On").expect(&content);
|
||||
|
||||
assert!(
|
||||
content.contains(&format!(
|
||||
"- **Owner**: alice\n- **Committed On**: {}\n- **Status**: committed\n",
|
||||
value
|
||||
)),
|
||||
"{content}"
|
||||
);
|
||||
assert!(content.ends_with("- **Status**: committed\n"), "{content}");
|
||||
}
|
||||
|
||||
/// Behind the refusals, all of them: a move that does not happen leaves the file exactly
|
||||
/// as it was, stamp included.
|
||||
#[test]
|
||||
fn mv_writes_no_stamp_when_the_move_is_refused() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let backward = stamped_ticket(&worklane, "committed");
|
||||
let before = ticket_at(&worklane, "committed", &backward);
|
||||
|
||||
let out = move_ticket(&temp, "cccc3333", "backlog", false);
|
||||
assert!(!out.status.success());
|
||||
assert_eq!(ticket_at(&worklane, "committed", &backward), before);
|
||||
|
||||
// The blocked ticket takes the other refusal, which sits after the no-op return.
|
||||
let blocked = create_gated_pair(&worklane, &temp, "backlog");
|
||||
let before = ticket_at(&worklane, "backlog", &blocked);
|
||||
|
||||
let out = move_ticket(&temp, "aaaa1111", "committed", false);
|
||||
assert!(!out.status.success());
|
||||
assert_eq!(ticket_at(&worklane, "backlog", &blocked), before);
|
||||
}
|
||||
|
||||
/// A move to the status the ticket is already in returns before anything is written, so
|
||||
/// it does not restamp either.
|
||||
#[test]
|
||||
fn mv_does_not_restamp_a_no_op_move() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = stamped_ticket(&worklane, "committed");
|
||||
let before = ticket_at(&worklane, "committed", &filename);
|
||||
|
||||
let out = move_ticket(&temp, "cccc3333", "committed", false);
|
||||
assert!(out.status.success());
|
||||
|
||||
assert_eq!(ticket_at(&worklane, "committed", &filename), before);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
/// The ticket under edit, the one it points at, and one that is already done.
|
||||
const GATED: &str = "641e3d5c-1b0e-4d2f-9a7e-3c8b5f0a2d61";
|
||||
const BLOCKER: &str = "b1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d";
|
||||
const FIXED: &str = "f1f2f3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn slug(title: &str) -> String {
|
||||
title
|
||||
.to_lowercase()
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric() || *c == ' ' || *c == '-' || *c == '_')
|
||||
.map(|c| if c == ' ' { '-' } else { c })
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A ticket with a ticked criterion and a section the tool knows nothing about, so
|
||||
/// every test can check that recording a relation leaves both exactly as they were.
|
||||
fn create_ticket(worklane: &Path, status: &str, title: &str, uuid: &str) -> PathBuf {
|
||||
let path = worklane
|
||||
.join(status)
|
||||
.join(format!("{}_{}.md", uuid, slug(title)));
|
||||
|
||||
fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"# {}\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
Prose.\n\
|
||||
\n\
|
||||
## Acceptance Criteria\n\
|
||||
- [x] Crit one\n\
|
||||
\n\
|
||||
## Implementation Plan\n\
|
||||
1. Step one\n\
|
||||
\n\
|
||||
## Notes\n\
|
||||
A handwritten note the tool knows nothing about.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {}\n\
|
||||
- **Priority**: 3\n\
|
||||
- **Tags**: alpha\n\
|
||||
- **Due**: _Not set_\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n\
|
||||
- **Status**: {}\n",
|
||||
title, uuid, status
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
path
|
||||
}
|
||||
|
||||
/// The three tickets every test starts from: the one being edited, one it can wait on,
|
||||
/// and one in done.
|
||||
fn board(temp: &TempDir) -> PathBuf {
|
||||
let worklane = setup_worklane(temp);
|
||||
create_ticket(&worklane, "backlog", "The gated one", GATED);
|
||||
create_ticket(&worklane, "backlog", "The blocker", BLOCKER);
|
||||
create_ticket(&worklane, "done", "The old fix", FIXED);
|
||||
worklane
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn stdout(out: &std::process::Output) -> String {
|
||||
String::from_utf8_lossy(&out.stdout).to_string()
|
||||
}
|
||||
|
||||
fn find(worklane: &Path, uuid: &str) -> PathBuf {
|
||||
for status in ["backlog", "committed", "reviewing", "done"] {
|
||||
let dir = worklane.join(status);
|
||||
for entry in fs::read_dir(&dir).unwrap().filter_map(|e| e.ok()) {
|
||||
if entry.file_name().to_string_lossy().starts_with(uuid) {
|
||||
return entry.path();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
panic!("no file for ticket {uuid}");
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path, uuid: &str) -> String {
|
||||
fs::read_to_string(find(worklane, uuid)).unwrap()
|
||||
}
|
||||
|
||||
/// All three tiers, since the target is a ticket argument like any other: a uuid
|
||||
/// prefix, a title substring, and a substring reaching the middle of the filename.
|
||||
#[test]
|
||||
fn a_target_resolves_by_uuid_prefix_title_or_filename() {
|
||||
for search in ["b1b2", "blocker", "4a7b"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--blocked-by", search]);
|
||||
assert!(
|
||||
out.status.success(),
|
||||
"{search}: {}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert!(
|
||||
ticket(&worklane, GATED).contains(&format!("- blocked by {}", BLOCKER)),
|
||||
"{search}: {}",
|
||||
ticket(&worklane, GATED)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_kind_is_recorded_under_its_own_label() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"relate",
|
||||
GATED,
|
||||
"--blocked-by",
|
||||
BLOCKER,
|
||||
"--regression-of",
|
||||
FIXED,
|
||||
"--relates-to",
|
||||
"old fix",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success());
|
||||
|
||||
let content = ticket(&worklane, GATED);
|
||||
assert!(content.contains(&format!("- blocked by {}", BLOCKER)), "{content}");
|
||||
assert!(content.contains(&format!("- regression of {}", FIXED)), "{content}");
|
||||
assert!(content.contains(&format!("- relates to {}", FIXED)), "{content}");
|
||||
|
||||
// Each kind named once in the report, whatever the order of the flags.
|
||||
let reported = stdout(&out);
|
||||
for kind in ["blocked by", "regression of", "relates to"] {
|
||||
assert!(reported.contains(kind), "{reported}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The kinds are flags, so anything else never reaches the file: clap refuses it with
|
||||
/// a usage error, exit code 2, and nothing is written.
|
||||
#[test]
|
||||
fn an_unknown_kind_is_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, GATED);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--depends-on", BLOCKER]);
|
||||
assert_eq!(out.status.code(), Some(2), "{}", stdout(&out));
|
||||
assert_eq!(ticket(&worklane, GATED), before);
|
||||
}
|
||||
|
||||
/// A bare `relate <ticket>` is a usage error too, not a silent no-op, the same way a
|
||||
/// bare `set` and a bare `append` are.
|
||||
#[test]
|
||||
fn a_relate_with_no_kind_is_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
board(&temp);
|
||||
|
||||
assert_eq!(run(&temp, &["relate", GATED]).status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// Between the plan and the metadata, created for a ticket written before the section
|
||||
/// existed, and behind a handwritten section rather than in front of it.
|
||||
#[test]
|
||||
fn the_section_is_created_in_its_place() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
let content = ticket(&worklane, GATED);
|
||||
let at = |heading: &str| content.find(heading).unwrap_or_else(|| panic!("{heading}"));
|
||||
assert!(at("## Implementation Plan") < at("## Relations"), "{content}");
|
||||
assert!(at("## Notes") < at("## Relations"), "{content}");
|
||||
assert!(at("## Relations") < at("## Metadata"), "{content}");
|
||||
}
|
||||
|
||||
/// The full uuid, not the seven characters `ls` prints, which is what makes the link
|
||||
/// survive a rename of the target and stay unambiguous as the board grows.
|
||||
#[test]
|
||||
fn the_stored_target_is_the_full_uuid() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
assert!(
|
||||
ticket(&worklane, GATED).contains(&format!("- blocked by {}\n", BLOCKER)),
|
||||
"{}",
|
||||
ticket(&worklane, GATED)
|
||||
);
|
||||
|
||||
run(&temp, &["set", BLOCKER, "--title", "Renamed entirely"]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(shown.contains("Renamed entirely"), "{shown}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ticket_cannot_relate_to_itself() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, GATED);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--relates-to", "gated"]);
|
||||
assert!(!out.status.success());
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("cannot relate to itself"),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane, GATED), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_relation_already_held_reports_no_change_and_writes_nothing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
let before = ticket(&worklane, GATED);
|
||||
|
||||
let out = run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
assert!(out.status.success());
|
||||
assert!(stdout(&out).contains("No changes"), "{}", stdout(&out));
|
||||
assert_eq!(
|
||||
ticket(&worklane, GATED),
|
||||
before,
|
||||
"the relation was recorded twice"
|
||||
);
|
||||
}
|
||||
|
||||
/// One direction is stored. The inverse is derived by a scan, so the ticket at the
|
||||
/// other end is not touched at all.
|
||||
#[test]
|
||||
fn only_the_ticket_named_is_written() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
let before = ticket(&worklane, BLOCKER);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
assert_eq!(ticket(&worklane, BLOCKER), before);
|
||||
assert!(!ticket(&worklane, BLOCKER).contains("Relations"));
|
||||
}
|
||||
|
||||
/// The tick, the handwritten section and the prose are what a regenerated file would
|
||||
/// lose, and the section is spliced in rather than rewritten around them.
|
||||
#[test]
|
||||
fn relate_leaves_everything_it_was_not_asked_about_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
let content = ticket(&worklane, GATED);
|
||||
assert!(content.contains("- [x] Crit one"), "the tick was lost: {content}");
|
||||
assert!(
|
||||
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
|
||||
"the unknown section was lost: {content}"
|
||||
);
|
||||
assert!(content.contains("1. Step one"), "{content}");
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
}
|
||||
|
||||
/// The mark each kind prints before the id. Written out rather than imported: these
|
||||
/// tests drive the binary, so they see only its output.
|
||||
///
|
||||
/// The cross is the one a held-up card already carries, since both say the same word.
|
||||
const BLOCKED_MARK: &str = "\u{d7}";
|
||||
const RELATES_MARK: &str = "\u{2192}";
|
||||
|
||||
/// And the mark for the status of the ticket the row names, which follows the kind: a
|
||||
/// circle filling up as the target moves through the flow.
|
||||
const BACKLOG_MARK: &str = "\u{25cb}";
|
||||
const DONE_MARK: &str = "\u{25cf}";
|
||||
/// A target the board no longer holds has no status, and `?` holds the column so the id
|
||||
/// does not move.
|
||||
const NO_STATUS_MARK: &str = "?";
|
||||
|
||||
/// The kind, the short id and the title, so the section reads without a second lookup.
|
||||
#[test]
|
||||
fn show_renders_the_kind_the_short_id_and_the_title() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(shown.contains("Relations"), "{shown}");
|
||||
assert!(
|
||||
shown.contains(&format!("blocked by {BLOCKED_MARK} {BACKLOG_MARK} (b1b2c3d) The blocker")),
|
||||
"{shown}"
|
||||
);
|
||||
// Never the stored line: a bare uuid says nothing about what it points at.
|
||||
assert!(!shown.contains(BLOCKER), "{shown}");
|
||||
}
|
||||
|
||||
/// Derived by scanning, since the file at this end holds nothing at all.
|
||||
#[test]
|
||||
fn show_lists_the_relation_the_other_ticket_holds() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
run(&temp, &["relate", GATED, "--relates-to", FIXED]);
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", BLOCKER]));
|
||||
assert!(
|
||||
shown.contains(&format!("blocks {BLOCKED_MARK} {BACKLOG_MARK} (641e3d5) The gated one")),
|
||||
"{shown}"
|
||||
);
|
||||
assert!(!ticket(&worklane, BLOCKER).contains("Relations"));
|
||||
|
||||
// Two kinds on one ticket, each with its own mark, and the second mark is the state
|
||||
// of the ticket at the far end: the old fix is in done and the blocker is not. That
|
||||
// is the pair the block is for, which kind of edge and whether it is finished.
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(
|
||||
shown.contains(&format!("blocked by {BLOCKED_MARK} {BACKLOG_MARK} (b1b2c3d) The blocker")),
|
||||
"{shown}"
|
||||
);
|
||||
assert!(
|
||||
shown.contains(&format!("relates to {RELATES_MARK} {DONE_MARK} (f1f2f3f) The old fix")),
|
||||
"{shown}"
|
||||
);
|
||||
|
||||
// `relates to` is symmetric, so it reads the same way from either end.
|
||||
let shown = stdout(&run(&temp, &["show", FIXED]));
|
||||
assert!(
|
||||
shown.contains(&format!("relates to {RELATES_MARK} {BACKLOG_MARK} (641e3d5) The gated one")),
|
||||
"{shown}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_target_that_no_longer_exists_renders_as_missing() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
run(&temp, &["relate", GATED, "--blocked-by", BLOCKER]);
|
||||
fs::remove_file(find(&worklane, BLOCKER)).unwrap();
|
||||
|
||||
let shown = stdout(&run(&temp, &["show", GATED]));
|
||||
assert!(
|
||||
shown.contains(&format!("blocked by {BLOCKED_MARK} {NO_STATUS_MARK} (b1b2c3d) _missing_")),
|
||||
"{shown}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The section is the one part of a ticket read back by machine, so a line nobody can
|
||||
/// parse is an error naming the ticket rather than a line quietly skipped.
|
||||
#[test]
|
||||
fn a_line_that_is_not_a_relation_is_an_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = board(&temp);
|
||||
|
||||
let path = find(&worklane, GATED);
|
||||
let content = fs::read_to_string(&path)
|
||||
.unwrap()
|
||||
.replace(
|
||||
"## Metadata",
|
||||
&format!("## Relations\n- depends on {}\n\n## Metadata", BLOCKER),
|
||||
);
|
||||
fs::write(&path, content).unwrap();
|
||||
|
||||
let out = run(&temp, &["show", GATED]);
|
||||
assert!(!out.status.success());
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
assert!(stderr.contains("is not a relation"), "{stderr}");
|
||||
assert!(stderr.contains("The gated one"), "{stderr}");
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
const UUID: &str = "475534a3-8a0d-45cb-9a97-39c251dd8e39";
|
||||
|
||||
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
/// A fully populated ticket, with one criterion already ticked and a section the tool
|
||||
/// knows nothing about, so every test can check both survive.
|
||||
fn create_ticket(worklane: &Path) -> String {
|
||||
let filename = format!("{}_original-title.md", UUID);
|
||||
fs::write(
|
||||
worklane.join("backlog").join(&filename),
|
||||
format!(
|
||||
"# Original title\n\
|
||||
\n\
|
||||
## Description\n\
|
||||
First paragraph.\n\
|
||||
\n\
|
||||
Second paragraph.\n\
|
||||
\n\
|
||||
## Acceptance Criteria\n\
|
||||
- [x] Crit one\n\
|
||||
- [ ] Crit two\n\
|
||||
\n\
|
||||
## Implementation Plan\n\
|
||||
1. Step one\n\
|
||||
2. Step two\n\
|
||||
\n\
|
||||
## Notes\n\
|
||||
A handwritten note the tool knows nothing about.\n\
|
||||
\n\
|
||||
## Metadata\n\
|
||||
\n\
|
||||
- **ID**: {}\n\
|
||||
- **Priority**: 3\n\
|
||||
- **Tags**: alpha\n\
|
||||
- **Due**: 2026-09-01\n\
|
||||
- **Owner**: alice\n\
|
||||
- **Created At**: 2026-08-21 02:10:17\n\
|
||||
- **Status**: backlog\n",
|
||||
UUID
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
filename
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
fn ticket(worklane: &Path) -> String {
|
||||
let entry = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.find(|e| e.file_name().to_string_lossy().ends_with(".md"))
|
||||
.expect("no ticket file");
|
||||
fs::read_to_string(entry.path()).unwrap()
|
||||
}
|
||||
|
||||
fn stray_files(worklane: &Path) -> Vec<String> {
|
||||
fs::read_dir(worklane)
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.filter(|name| {
|
||||
!["backlog", "committed", "reviewing", "done", "comments"].contains(&name.as_str())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_replaces_each_field_it_is_given() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"set", UUID,
|
||||
"--description", "Only paragraph.",
|
||||
"--acceptance", "New crit",
|
||||
"--plan", "New step",
|
||||
"--tags", "beta,gamma",
|
||||
"--due", "2026-12-31",
|
||||
"--priority", "1",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("## Description\nOnly paragraph.\n"), "{content}");
|
||||
assert!(content.contains("## Acceptance Criteria\n- [ ] New crit\n"), "{content}");
|
||||
assert!(content.contains("## Implementation Plan\n1. New step\n"), "{content}");
|
||||
assert!(content.contains("- **Tags**: beta,gamma"), "{content}");
|
||||
assert!(content.contains("- **Due**: 2026-12-31"), "{content}");
|
||||
assert!(content.contains("- **Priority**: 1"), "{content}");
|
||||
|
||||
// The fields it was not given are untouched
|
||||
assert!(content.contains("- **Owner**: alice"), "{content}");
|
||||
assert!(content.contains("- **Status**: backlog"), "{content}");
|
||||
}
|
||||
|
||||
/// The criterion is ticked in the fixture, so an unrelated edit must leave it ticked.
|
||||
#[test]
|
||||
fn set_leaves_a_ticked_criterion_and_an_unknown_section_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["set", UUID, "--due", "2026-12-31"]);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] Crit one"), "the tick was lost: {content}");
|
||||
assert!(
|
||||
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
|
||||
"the unknown section was lost: {content}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_renames_the_file_for_a_new_title_and_keeps_the_uuid() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["set", UUID, "--title", "A brand new title"]);
|
||||
|
||||
let names: Vec<String> = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.collect();
|
||||
assert_eq!(names, vec![format!("{}_a-brand-new-title.md", UUID)]);
|
||||
assert!(ticket(&worklane).starts_with("# A brand new title\n"));
|
||||
|
||||
// And the renamed ticket is still reachable, by the new title and by the uuid
|
||||
for search in ["brand new", "475534a3"] {
|
||||
let out = run(&temp, &["show", search]);
|
||||
assert!(out.status.success(), "{search} did not resolve");
|
||||
assert!(String::from_utf8_lossy(&out.stdout).contains("A brand new title"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_reports_no_change_and_leaves_the_file_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["set", UUID, "--due", "2026-09-01", "--priority", "3"]);
|
||||
assert!(out.status.success());
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stdout).contains("No changes"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stdout)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before, "the file was rewritten anyway");
|
||||
}
|
||||
|
||||
/// Only the field that actually differs is claimed, so the report cannot overstate.
|
||||
#[test]
|
||||
fn set_reports_only_the_fields_that_changed() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["set", UUID, "--due", "2026-09-01", "--priority", "5"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert!(stdout.contains("priority"), "{stdout:?}");
|
||||
assert!(!stdout.contains("due"), "{stdout:?}");
|
||||
}
|
||||
|
||||
/// An empty scalar looks like a way to clear a field, and clearing is not supported.
|
||||
#[test]
|
||||
fn set_refuses_an_empty_scalar_as_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
for flag in ["--title", "--due", "--tags"] {
|
||||
let out = run(&temp, &["set", UUID, flag, ""]);
|
||||
assert_eq!(out.status.code(), Some(2), "{flag} was accepted");
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("clearing a field is not supported"),
|
||||
"{flag}: {:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
}
|
||||
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// An empty value is a paragraph break for a section, so an all-blank one is a
|
||||
/// clearing attempt rather than a break.
|
||||
#[test]
|
||||
fn set_refuses_to_clear_a_section() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["set", UUID, "--description", ""]);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("clearing is not supported"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
/// A bare `set <ticket>` would otherwise be a silent no-op.
|
||||
#[test]
|
||||
fn set_requires_at_least_one_field() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["set", UUID]);
|
||||
assert_eq!(out.status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// Interior blanks are paragraph breaks, per 4c516e6, so they have to reach the file.
|
||||
#[test]
|
||||
fn set_keeps_a_paragraph_break_in_a_replaced_description() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(
|
||||
&temp,
|
||||
&["set", UUID, "-d", "One.", "-d", "", "-d", "Two."],
|
||||
);
|
||||
|
||||
assert!(
|
||||
ticket(&worklane).contains("## Description\nOne.\n\nTwo.\n\n## Acceptance"),
|
||||
"{}",
|
||||
ticket(&worklane)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_accepts_prose_that_begins_with_a_hyphen() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&["set", UUID, "-a", "--print should be supported", "-t", "-t is the title flag"],
|
||||
);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [ ] --print should be supported"), "{content}");
|
||||
assert!(content.starts_with("# -t is the title flag\n"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_leaves_nothing_behind() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["set", UUID, "--due", "2026-12-31"]);
|
||||
assert_eq!(stray_files(&worklane), Vec::<String>::new());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_adds_a_paragraph_items_and_numbered_steps() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&[
|
||||
"append", UUID,
|
||||
"-d", "A third paragraph.",
|
||||
"-a", "Crit three",
|
||||
"-a", "Crit four",
|
||||
"-p", "Step three",
|
||||
],
|
||||
);
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(
|
||||
content.contains("Second paragraph.\n\nA third paragraph.\n"),
|
||||
"no paragraph break: {content}"
|
||||
);
|
||||
assert!(
|
||||
content.contains("- [x] Crit one\n- [ ] Crit two\n- [ ] Crit three\n- [ ] Crit four\n"),
|
||||
"{content}"
|
||||
);
|
||||
// Numbered on from the last step, and the steps above are untouched
|
||||
assert!(
|
||||
content.contains("1. Step one\n2. Step two\n3. Step three\n"),
|
||||
"{content}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_replaces_an_empty_section_rather_than_following_its_placeholder() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let mut add = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
add.current_dir(temp.path())
|
||||
.args(["add", "--title", "Bare ticket"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let uuid = fs::read_dir(worklane.join("backlog"))
|
||||
.unwrap()
|
||||
.filter_map(|e| e.ok())
|
||||
.map(|e| e.file_name().into_string().unwrap())
|
||||
.next()
|
||||
.map(|name| name.split('_').next().unwrap().to_string())
|
||||
.unwrap();
|
||||
|
||||
run(
|
||||
&temp,
|
||||
&["append", &uuid, "-d", "A description arrives late.", "-a", "First crit", "-p", "First step"],
|
||||
);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(!content.contains("_No description provided._"), "{content}");
|
||||
assert!(!content.contains("_No acceptance criteria provided._"), "{content}");
|
||||
assert!(!content.contains("_No implementation plan provided._"), "{content}");
|
||||
assert!(content.contains("## Description\nA description arrives late.\n"), "{content}");
|
||||
assert!(content.contains("## Implementation Plan\n1. First step\n"), "{content}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_leaves_a_ticked_criterion_and_an_unknown_section_alone() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
run(&temp, &["append", UUID, "-a", "Crit three"]);
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- [x] Crit one"), "{content}");
|
||||
assert!(
|
||||
content.contains("## Notes\nA handwritten note the tool knows nothing about.\n"),
|
||||
"{content}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_refuses_when_every_value_is_blank() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
let before = ticket(&worklane);
|
||||
|
||||
let out = run(&temp, &["append", UUID, "-a", " "]);
|
||||
assert_eq!(out.status.code(), Some(1));
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains("Nothing to append"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out.stderr)
|
||||
);
|
||||
assert_eq!(ticket(&worklane), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_requires_at_least_one_section() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
assert_eq!(run(&temp, &["append", UUID]).status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// Owner belongs to chown and status to mv, so neither command offers them.
|
||||
#[test]
|
||||
fn neither_command_can_write_owner_or_status() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
create_ticket(&worklane);
|
||||
|
||||
for args in [
|
||||
vec!["set", UUID, "--owner", "bob"],
|
||||
vec!["set", UUID, "--status", "committed"],
|
||||
vec!["append", UUID, "--owner", "bob"],
|
||||
] {
|
||||
let out = run(&temp, &args);
|
||||
assert_eq!(out.status.code(), Some(2), "{args:?} was accepted");
|
||||
}
|
||||
|
||||
let content = ticket(&worklane);
|
||||
assert!(content.contains("- **Owner**: alice"));
|
||||
assert!(content.contains("- **Status**: backlog"));
|
||||
}
|
||||
|
||||
/// The same parser `add` uses, from one definition. Grooming a board sets dates through
|
||||
/// `set`, so validating only the command that files a ticket would leave the path that
|
||||
/// is actually used wide open.
|
||||
#[test]
|
||||
fn set_refuses_a_due_date_that_is_not_a_real_iso_date() {
|
||||
for value in ["next friday", "2026-02-30", "2026-8-9"] {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_ticket(&worklane);
|
||||
let before = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
let out = cmd
|
||||
.current_dir(temp.path())
|
||||
.args(["set", UUID])
|
||||
.args(["--due", value])
|
||||
.assert()
|
||||
.failure()
|
||||
.get_output()
|
||||
.clone();
|
||||
|
||||
assert_eq!(out.status.code(), Some(2), "{value:?} was not a usage error");
|
||||
assert_eq!(
|
||||
fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap(),
|
||||
before,
|
||||
"{value:?} changed the ticket anyway"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_stores_a_valid_due_date_unchanged() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
let filename = create_ticket(&worklane);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
.args(["set", UUID])
|
||||
.args(["--due", "2026-12-31"])
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
let content = fs::read_to_string(worklane.join("backlog").join(&filename)).unwrap();
|
||||
assert!(content.contains("- **Due**: 2026-12-31"), "{content}");
|
||||
}
|
||||
+241
-15
@@ -16,8 +16,11 @@ fn setup_worklane(temp: &TempDir) -> std::path::PathBuf {
|
||||
worklane.path().to_path_buf()
|
||||
}
|
||||
|
||||
/// Same fixture, same trade as `cmd_mv.rs`: positional today, a struct when the call
|
||||
/// sites in both files are converted together.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn create_ticket(
|
||||
worklane_dir: &std::path::PathBuf,
|
||||
worklane_dir: &std::path::Path,
|
||||
status: &str,
|
||||
title: &str,
|
||||
description: &str,
|
||||
@@ -86,7 +89,7 @@ fn show_displays_ticket_by_full_uuid() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("abc123def456789012345678901234567890")
|
||||
.assert()
|
||||
@@ -118,7 +121,7 @@ fn show_displays_ticket_by_partial_uuid() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("abc123def4567890")
|
||||
.assert()
|
||||
@@ -147,7 +150,7 @@ fn show_displays_ticket_by_title() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("login")
|
||||
.assert()
|
||||
@@ -178,7 +181,7 @@ fn show_displays_ticket_by_partial_title() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("fix")
|
||||
.assert()
|
||||
@@ -206,7 +209,7 @@ fn show_shows_both_uuid_and_title_in_output() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("test")
|
||||
.assert()
|
||||
@@ -222,7 +225,7 @@ fn show_fails_for_nonexistent_ticket() {
|
||||
setup_worklane(&temp);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("nonexistent")
|
||||
.assert()
|
||||
@@ -259,7 +262,7 @@ fn show_asks_for_disambiguation_when_multiple_matches() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("est");
|
||||
cmd.current_dir(temp.path()).arg("show").arg("est");
|
||||
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Multiple tickets found"));
|
||||
@@ -299,7 +302,7 @@ fn show_reports_ambiguity_on_stderr_with_a_failing_exit() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("ambiguous")
|
||||
.assert()
|
||||
@@ -333,7 +336,7 @@ fn show_disambiguates_tickets_with_short_filenames() {
|
||||
.unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("short");
|
||||
cmd.current_dir(temp.path()).arg("show").arg("short");
|
||||
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Multiple tickets found"));
|
||||
@@ -356,7 +359,7 @@ fn show_disambiguates_tickets_with_non_ascii_filenames() {
|
||||
}
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("accented");
|
||||
cmd.current_dir(temp.path()).arg("show").arg("accented");
|
||||
|
||||
let stderr = get_stderr(&mut cmd);
|
||||
assert!(stderr.contains("Multiple tickets found"));
|
||||
@@ -383,7 +386,7 @@ fn show_searches_across_all_statuses() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path())
|
||||
cmd.current_dir(temp.path())
|
||||
.arg("show")
|
||||
.arg("committed")
|
||||
.assert()
|
||||
@@ -408,7 +411,7 @@ fn show_renders_the_priority_mark_beside_the_number() {
|
||||
.unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("Prio");
|
||||
cmd.current_dir(temp.path()).arg("show").arg("Prio");
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
// Mark for the eye, number still there for the file's sake
|
||||
@@ -438,7 +441,7 @@ fn show_prints_the_title_once() {
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("Once Only");
|
||||
cmd.current_dir(temp.path()).arg("show").arg("Once Only");
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
assert_eq!(
|
||||
@@ -467,7 +470,7 @@ fn show_renders_the_metadata_as_an_aligned_table() {
|
||||
.unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(&temp.path()).arg("show").arg("Table");
|
||||
cmd.current_dir(temp.path()).arg("show").arg("Table");
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
// Every value starts in the same column, sized by the longest field name
|
||||
@@ -485,3 +488,226 @@ fn show_renders_the_metadata_as_an_aligned_table() {
|
||||
let content = fs::read_to_string(worklane.join("backlog").join(filename)).unwrap();
|
||||
assert!(content.contains("- **Owner**: alice"));
|
||||
}
|
||||
|
||||
/// The stamps `mv` writes are fields like any other: the table renders what the file
|
||||
/// holds, so nothing here knows their names, and the column widens to the longest of
|
||||
/// them the way it does for anything else.
|
||||
#[test]
|
||||
fn show_renders_a_status_stamp_in_the_metadata_table() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let filename = "abc123def456789012345678901234567890_stamped.md";
|
||||
fs::write(
|
||||
worklane.join("committed").join(filename),
|
||||
"# Stamped Ticket\n\n## Metadata\n\n\
|
||||
- **ID**: abc123def456789012345678901234567890\n\
|
||||
- **Created At**: 2026-08-20 15:51:01\n\
|
||||
- **Committed On**: 2026-08-22 09:14:30\n\
|
||||
- **Status**: committed\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).arg("show").arg("Stamped");
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
assert!(
|
||||
stdout.contains(
|
||||
"Created At 2026-08-20 15:51:01\n\
|
||||
Committed On 2026-08-22 09:14:30\n\
|
||||
Status committed\n"
|
||||
),
|
||||
"{stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Write a ticket with an exact uuid and title, since both matter to resolution.
|
||||
fn ticket_with(worklane: &std::path::Path, status: &str, uuid: &str, title: &str, slug: &str) {
|
||||
fs::write(
|
||||
worklane.join(status).join(format!("{}_{}.md", uuid, slug)),
|
||||
format!(
|
||||
"# {}\n\n## Metadata\n\n- **ID**: {}\n- **Status**: {}\n",
|
||||
title, uuid, status
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn show(temp: &TempDir, search: &str) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).arg("show").arg(search);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
/// The bug. A flat OR of the three predicates put an exact uuid prefix and a title
|
||||
/// that merely mentions it in the same list, so the search reported as ambiguous
|
||||
/// the very id the listing had just printed.
|
||||
#[test]
|
||||
fn show_prefers_a_uuid_prefix_over_a_title_that_mentions_it() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||
"Alpha",
|
||||
"alpha",
|
||||
);
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
||||
"Notes on 641e3d5 regression",
|
||||
"notes",
|
||||
);
|
||||
|
||||
let out = show(&temp, "641e3d5");
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(stdout.contains("Alpha"), "{stdout:?}");
|
||||
assert!(!stdout.contains("Notes on"), "{stdout:?}");
|
||||
}
|
||||
|
||||
/// `ls` prints SHORT_ID_WIDTH characters, so pasting that back has to resolve. This
|
||||
/// is the guard against reinstating an eight character minimum.
|
||||
#[test]
|
||||
fn show_resolves_the_short_id_the_listing_prints() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let uuid = "641e3d5d-ef23-4213-8346-e8b0114b84e9";
|
||||
ticket_with(&worklane, "backlog", uuid, "Alpha", "alpha");
|
||||
|
||||
let mut ls = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
ls.current_dir(temp.path()).args(["ls", "backlog"]);
|
||||
let listing = String::from_utf8(ls.assert().success().get_output().stdout.clone()).unwrap();
|
||||
|
||||
// Take the id exactly as printed, so this couples to the display width rather
|
||||
// than to a hardcoded number
|
||||
let printed = listing
|
||||
.split('(')
|
||||
.nth(1)
|
||||
.and_then(|rest| rest.split(')').next())
|
||||
.expect("no id in the listing")
|
||||
.to_string();
|
||||
assert!(printed.len() < 8, "the listing prints {} chars", printed.len());
|
||||
|
||||
// A decoy whose title quotes that id. Without it the search would still land on
|
||||
// Alpha through the filename tier, since the filename contains the uuid, and the
|
||||
// test would pass under a minimum longer than the printed id.
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
||||
&format!("Notes on {} regression", printed),
|
||||
"notes",
|
||||
);
|
||||
|
||||
let out = show(&temp, &printed);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(out.status.success(), "{printed} did not resolve");
|
||||
assert!(stdout.contains("Alpha"), "{stdout:?}");
|
||||
assert!(!stdout.contains("Notes on"), "{stdout:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn show_resolves_a_four_character_uuid_prefix() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||
"Alpha",
|
||||
"alpha",
|
||||
);
|
||||
|
||||
let out = show(&temp, "641e");
|
||||
assert!(out.status.success());
|
||||
assert!(String::from_utf8_lossy(&out.stdout).contains("Alpha"));
|
||||
}
|
||||
|
||||
/// Below four characters the search is text, so it must not be read as a prefix
|
||||
/// matching a large slice of the board.
|
||||
#[test]
|
||||
fn show_treats_a_search_below_four_characters_as_text() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||
"Alpha",
|
||||
"alpha",
|
||||
);
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
||||
"Notes on 641 regression",
|
||||
"notes",
|
||||
);
|
||||
|
||||
// "641" prefixes Alpha's uuid, but it is too short to be read as one, so the
|
||||
// title match is the only match
|
||||
let out = show(&temp, "641");
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert!(out.status.success(), "{:?}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(stdout.contains("Notes on"), "{stdout:?}");
|
||||
assert!(!stdout.contains("Alpha"), "{stdout:?}");
|
||||
}
|
||||
|
||||
/// The last tier earns its place: it reaches the middle of a uuid, which the prefix
|
||||
/// tier cannot.
|
||||
#[test]
|
||||
fn show_falls_back_to_the_filename_for_a_mid_uuid_substring() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"641e3d5d-ef23-4213-8346-e8b0114b84e9",
|
||||
"Alpha",
|
||||
"alpha",
|
||||
);
|
||||
|
||||
let out = show(&temp, "ef23");
|
||||
assert!(out.status.success());
|
||||
assert!(String::from_utf8_lossy(&out.stdout).contains("Alpha"));
|
||||
}
|
||||
|
||||
/// Tiering removes false ambiguity across tiers, not real ambiguity inside one.
|
||||
#[test]
|
||||
fn show_still_reports_ambiguity_within_the_uuid_tier() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"5eeddeed-1111-2222-3333-444444444444",
|
||||
"Beta",
|
||||
"beta",
|
||||
);
|
||||
ticket_with(
|
||||
&worklane,
|
||||
"backlog",
|
||||
"5eedbeef-9999-8888-7777-666666666666",
|
||||
"Gamma",
|
||||
"gamma",
|
||||
);
|
||||
|
||||
let out = show(&temp, "5eed");
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert!(!out.status.success());
|
||||
assert!(stderr.contains("Multiple tickets found"), "{stderr:?}");
|
||||
assert!(stderr.contains("Beta") && stderr.contains("Gamma"), "{stderr:?}");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
use assert_cmd::Command;
|
||||
use assert_fs::TempDir;
|
||||
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||
|
||||
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||
|
||||
fn setup_worklane(temp: &TempDir) {
|
||||
let worklane = temp.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
/// A project inside the temp directory, for the path arguments. The temp directory
|
||||
/// itself is left without a board, so a path that resolves has to resolve to this one.
|
||||
fn setup_project(temp: &TempDir, name: &str) -> std::path::PathBuf {
|
||||
let project = temp.child(name);
|
||||
let worklane = project.child(".worklane");
|
||||
worklane.create_dir_all().unwrap();
|
||||
|
||||
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||
worklane.child(dir).create_dir_all().unwrap();
|
||||
}
|
||||
|
||||
project.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn run(temp: &TempDir, args: &[&str]) -> std::process::Output {
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(args);
|
||||
cmd.assert().get_output().clone()
|
||||
}
|
||||
|
||||
/// Same message every other command gives. Checked before the terminal is, so the
|
||||
/// missing board is what gets reported rather than the missing tty.
|
||||
#[test]
|
||||
fn the_tui_outside_a_worklane_directory_gives_the_usual_message() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
for args in [vec!["tui"], vec![]] {
|
||||
let out = run(&temp, &args);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
||||
assert!(
|
||||
stderr.contains("No .worklane directory found"),
|
||||
"{args:?}: {stderr:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Raw mode on a pipe fails with a bare "No such device or address", which says nothing
|
||||
/// about the mistake. A bare `worklane` is how the board opens, so a script that lands
|
||||
/// here by accident has to be pointed at a subcommand.
|
||||
#[test]
|
||||
fn the_tui_without_a_terminal_says_so_and_names_an_alternative() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
for args in [vec!["tui"], vec![]] {
|
||||
let out = run(&temp, &args);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{args:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{args:?}: {stderr:?}");
|
||||
assert!(stderr.contains("worklane ls"), "{args:?}: {stderr:?}");
|
||||
assert!(
|
||||
!stderr.contains("os error"),
|
||||
"the raw mode error leaked: {stderr:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The subcommands must keep working now that the subcommand is optional.
|
||||
#[test]
|
||||
fn an_unknown_subcommand_is_still_a_usage_error() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
setup_worklane(&temp);
|
||||
|
||||
assert_eq!(run(&temp, &["nonsense"]).status.code(), Some(2));
|
||||
assert_eq!(run(&temp, &["--bogus"]).status.code(), Some(2));
|
||||
}
|
||||
|
||||
/// A path argument is resolved before the terminal is, the same way the working
|
||||
/// directory is: reaching the tty complaint is what says the board was found.
|
||||
#[test]
|
||||
fn a_path_argument_names_the_board_to_open() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let project = setup_project(&temp, "project");
|
||||
|
||||
// Run from a directory with no board of its own, so only the argument can find one.
|
||||
let out = run(&temp, &["tui", project.to_str().unwrap()]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// And several of them, which is the point of taking paths at all.
|
||||
#[test]
|
||||
fn several_path_arguments_are_accepted() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let first = setup_project(&temp, "first");
|
||||
let second = setup_project(&temp, "second");
|
||||
|
||||
let out = run(
|
||||
&temp,
|
||||
&["tui", first.to_str().unwrap(), second.to_str().unwrap()],
|
||||
);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains("needs a terminal"), "{stderr:?}");
|
||||
}
|
||||
|
||||
/// With several paths, "No .worklane directory found" does not say which one was wrong.
|
||||
#[test]
|
||||
fn a_path_with_no_board_is_named_in_the_failure() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let project = setup_project(&temp, "project");
|
||||
|
||||
let elsewhere = temp.child("elsewhere");
|
||||
elsewhere.create_dir_all().unwrap();
|
||||
let path = elsewhere.path().to_str().unwrap().to_string();
|
||||
|
||||
// The first path resolves, the second does not.
|
||||
let out = run(&temp, &["tui", project.to_str().unwrap(), &path]);
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
|
||||
assert_eq!(out.status.code(), Some(1), "{stderr:?}");
|
||||
assert!(stderr.contains(&path), "the failing path is not named: {stderr:?}");
|
||||
assert!(
|
||||
stderr.contains("No .worklane directory found"),
|
||||
"the usual message is gone: {stderr:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// `tui` has to appear in the help, or nothing points at it.
|
||||
#[test]
|
||||
fn the_help_lists_the_tui_command() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
|
||||
let out = run(&temp, &["--help"]);
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
|
||||
assert!(out.status.success());
|
||||
assert!(stdout.contains("tui"), "{stdout:?}");
|
||||
}
|
||||
Reference in New Issue
Block a user