(55ee6e3) Complete campaigns and tags, and bump to 0.19.0

Every argument naming a campaign or a tag fell through to nothing: `campaign
show <TAB>`, `assign <TAB>`, `ls --campaign <TAB>` and `ls --tag <TAB>`. Neither
value had a listing a completion could parse.

`campaign ls --ids` is the same flag and the same two fields as `ls --ids`,
since it answers the same question about a different object. It skips the member
counting the decorated listing does, because `members()` reads every ticket on
the board and the caller is a shell on a keypress, and it prints nothing on an
empty board where the decorated listing prints a sentence.

Tags get a command rather than a mode on `ls`. `ls --tag <tag>` answers what
carries a tag and cannot answer what tags exist, which is the question a
grooming sweep starts from, and a `--tags` beside a `--tag` is one letter from a
filter that means something else. `worklane tags` prints the tag, a tab and the
count, alphabetical and case sensitive like the filter, so `bug` and `Bug` list
separately and land next to each other. assets/PLAN.md used to tell the agent to
count the vocabulary with a `show` per ticket; it now points here.

The fish half gains `__worklane_nested_arg_of`, which matches a parent and a
child, because `campaign show <TAB>` and `chown alice <TAB>` sit at the same
token count and the two counting helpers cannot tell them apart.

It also gains `__worklane_command_is`, which fixes a leak the campaign and tag
rules would have joined. A bare `complete -c worklane -l tag` does not only
complete that option's values, it tells fish the whole tool accepts `--tag`:
`worklane init --<TAB>` offered `--blocked-by`, `--regression-of`,
`--relates-to` and three others. `relate`'s three were already leaking that way,
so all of them are scoped now rather than leaving a correctly scoped twin beside
a wrong one. `__fish_seen_subcommand_from ls` is not the scope to use, since
`campaign ls` is an `ls` fish has seen.

The honesty tests grow to five lists and one walker, `every_argument`, since
they differ only in the id they look for. Each asserts how many arguments it
found, so a walker that stopped finding them fails rather than passing every
assertion by never running it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-23 01:16:51 +02:00
co-authored by Claude Opus 5
parent 6a800fb385
commit c65e1b4ed7
12 changed files with 571 additions and 40 deletions
+41
View File
@@ -413,6 +413,47 @@ fn campaign_ls_lists_campaigns_with_their_member_counts() {
assert!(listing.contains("v2 release | no members"), "{listing}");
}
/// The machine-readable listing, the same two fields and the same shape as `ls --ids`.
#[test]
fn campaign_ls_ids_prints_the_id_and_the_title_tab_separated() {
let temp = TempDir::new().unwrap();
let _worklane = board(&temp);
run(&temp, &["assign", "v1 release", MEMBER]);
let out = run(&temp, &["campaign", "ls", "--ids"]);
assert!(out.status.success(), "{}", stderr(&out));
let listing = stdout(&out);
assert_eq!(
listing.lines().collect::<Vec<_>>(),
vec![
format!("{}\tv1 release", &CAMP_A[..7]),
format!("{}\tv2 release", &CAMP_B[..7]),
]
);
// Nothing decorated: no heading, no member count, no escape.
assert!(!listing.contains("Campaigns:"), "{listing}");
assert!(!listing.contains("done"), "{listing}");
assert!(!listing.contains('\u{1b}'), "{listing}");
}
/// A completion offers nothing rather than a sentence, so the empty case that prints
/// prose for a reader has to stay out of the parsed path.
#[test]
fn campaign_ls_ids_says_nothing_on_a_board_with_no_campaigns() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
let out = run(&temp, &["campaign", "ls", "--ids"]);
assert!(out.status.success(), "{}", stderr(&out));
assert_eq!(stdout(&out), "");
// The decorated listing still explains itself.
assert!(stdout(&run(&temp, &["campaign", "ls"])).contains("No campaigns yet"));
}
/// 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]
+177
View File
@@ -0,0 +1,177 @@
//! `worklane tags`, the tag vocabulary.
//!
//! The command exists because `--tag` answers what carries a tag and cannot answer what
//! tags exist, which is the question a grooming sweep starts from. So the properties
//! under test are the ones that question needs: every status counted, case kept apart,
//! alphabetical order, and an output a shell can parse.
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");
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 ticket carrying `tags` verbatim, so a test can write the field the way a hand-made
/// ticket would: spaced, unspaced, unset or absent.
fn create_ticket(worklane: &Path, status: &str, uuid: &str, tags: &str) {
let path = worklane.join(status).join(format!("{uuid}_ticket.md"));
fs::write(
&path,
format!(
"# Ticket {uuid}\n\
\n\
## Description\n\
Prose that says **Tags**: not-a-field, in the body.\n\
\n\
## Metadata\n\
\n\
- **ID**: {uuid}\n\
- **Priority**: 3\n\
- **Tags**: {tags}\n\
- **Owner**: alice\n\
- **Created At**: 2026-08-21 02:10:17\n\
- **Status**: {status}\n"
),
)
.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 tags(temp: &TempDir) -> Vec<String> {
let out = run(temp, &["tags"]);
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
String::from_utf8_lossy(&out.stdout)
.lines()
.map(str::to_string)
.collect()
}
/// Every status, done included, and the count is tickets rather than mentions.
#[test]
fn tags_counts_every_tag_on_the_board() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "bug, cli");
create_ticket(&worklane, "committed", "22222222", "bug,tui");
create_ticket(&worklane, "done", "33333333", "bug");
assert_eq!(tags(&temp), vec!["bug\t3", "cli\t1", "tui\t1"]);
}
/// Alphabetical, which is the property that makes a near-duplicate findable: the two
/// spellings land next to each other.
#[test]
fn tags_are_alphabetical_so_near_duplicates_are_adjacent() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "tui,bug,bugfix,cli");
assert_eq!(tags(&temp), vec!["bug\t1", "bugfix\t1", "cli\t1", "tui\t1"]);
}
/// Case sensitive, like the `--tag` filter. Folding the two together here would hide the
/// reason a filter came back short.
#[test]
fn tags_keeps_case_apart_the_way_the_filter_does() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "bug");
create_ticket(&worklane, "backlog", "22222222", "Bug");
assert_eq!(tags(&temp), vec!["Bug\t1", "bug\t1"]);
// And the filter agrees with the listing, which is the point of keeping them apart.
let filtered = String::from_utf8_lossy(&run(&temp, &["ls", "--tag", "bug", "--ids"]).stdout)
.lines()
.count();
assert_eq!(filtered, 1);
}
/// An unset field, an absent one and a field of separators are all no tags, the same
/// three cases `parse_tags` folds together.
#[test]
fn tags_ignores_a_ticket_with_nothing_to_count() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "_None_");
create_ticket(&worklane, "backlog", "22222222", " , ,");
create_ticket(&worklane, "backlog", "33333333", "");
// No Tags field at all, the way a hand-made ticket can be.
fs::write(
worklane.join("backlog").join("44444444_bare.md"),
"# Bare\n\n## Metadata\n\n- **ID**: 44444444\n- **Status**: backlog\n",
)
.unwrap();
create_ticket(&worklane, "backlog", "55555555", "real");
assert_eq!(tags(&temp), vec!["real\t1"]);
}
/// A board with no tags prints nothing rather than a sentence, since a completion reads
/// this and a sentence would become a candidate.
#[test]
fn tags_says_nothing_on_a_board_with_no_tags() {
let temp = TempDir::new().unwrap();
setup_worklane(&temp);
let out = run(&temp, &["tags"]);
assert!(out.status.success());
assert_eq!(String::from_utf8_lossy(&out.stdout), "");
}
/// Unstyled, like `ls --ids`: a shell reads this and an escape sequence would land in
/// the candidate.
#[test]
fn tags_is_unstyled() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "bug");
let listing = String::from_utf8_lossy(&run(&temp, &["tags"]).stdout).to_string();
assert!(!listing.contains('\u{1b}'), "{listing:?}");
}
/// The Tags line in a Description is prose, not a field, the same rule every other
/// metadata read follows.
#[test]
fn tags_reads_only_the_metadata_section() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "bug");
assert_eq!(tags(&temp), vec!["bug\t1"]);
}
/// A missing status directory is skipped rather than refused, as in `ls --ids`: the
/// caller is usually a shell, and an error over the prompt is worse than fewer answers.
#[test]
fn tags_skips_a_missing_status_directory() {
let temp = TempDir::new().unwrap();
let worklane = setup_worklane(&temp);
create_ticket(&worklane, "backlog", "11111111", "bug");
fs::remove_dir_all(worklane.join("reviewing")).unwrap();
assert_eq!(tags(&temp), vec!["bug\t1"]);
}