(61879a4) Surface campaigns on the board, and bump to 0.20.0
A card label and a frame, not a campaign tab. A tab had to say what its columns are, and a campaign groups across the flow rather than within one status, so the answer is the four columns filtered: a filter on the board it already has, not a fifth tab. So a card names its campaign on the label row, before the tags, marked ~ and bold, and the row drops the tags whole before it drops the campaign. `c` opens a picker; taking a campaign filters every column to its members and draws a frame above them carrying the id, the codename, the name, the opening line of the description and the standing. The standing comes from the columns, since while a campaign is selected the columns are its members. `q` takes off one layer at a time: the overlay, the filter, the board. The label needs something to say, which the stored uuid is not, so campaigns gained `Codename`: one word, `v1` or `beaver`, written by `campaign add --codename` and validated at parse time. `campaign ls` prints it and `resolve_in` gained an exact-codename tier above the uuid prefix, or it would be a field you can read and cannot type. Only campaigns carry the field, so the tier is empty for a ticket and ticket resolution is unchanged. The campaigns index is read once per project in `columns_of`, on the pass that already builds the cards, and `digest` now watches the campaigns directory: without it a campaign filed elsewhere never reached the picker. `frame_rows` grew a row, so the two bools deciding the geometry became one `Chrome` and the row indices are named. Left out and filed as d637288: nothing can give a codename to a campaign that is already on the board. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
c65e1b4ed7
commit
528566d103
+24
-1
@@ -41,6 +41,12 @@ pub fn ensure_campaigns_dir(worklane_dir: &Path) -> Result<PathBuf> {
|
||||
pub struct Campaign {
|
||||
pub uuid: String,
|
||||
pub title: String,
|
||||
/// The word the campaign is called by, or `None` for one filed without a codename.
|
||||
///
|
||||
/// Read here rather than parsed at each call site for the reason the title is: the
|
||||
/// board draws it on every card that names this campaign, and the picker draws it on
|
||||
/// every row, so it comes off the one read of the directory.
|
||||
pub codename: Option<String>,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
@@ -80,6 +86,7 @@ pub fn resolve_campaign(search: &str, worklane_dir: &Path) -> Result<Campaign> {
|
||||
}
|
||||
|
||||
Ok(Campaign {
|
||||
codename: parse_codename(&found.content),
|
||||
uuid,
|
||||
title: found.title,
|
||||
content: found.content,
|
||||
@@ -103,6 +110,11 @@ pub fn campaign_named(search: &str, worklane_dir: &Path) -> Option<String> {
|
||||
/// One pass for the same reason [`RelationIndex`] takes one: rendering a ticket's
|
||||
/// Campaign field or listing the campaigns both need every one of them, and a lookup
|
||||
/// per ticket would read the directory once per row.
|
||||
///
|
||||
/// `Default` is the empty index, which is what a board whose campaigns directory cannot be
|
||||
/// read has: it still draws, with no campaign on any card. A *missing* directory is already
|
||||
/// not an error, per [`CampaignIndex::load`]; this is for the unreadable one.
|
||||
#[derive(Default)]
|
||||
pub struct CampaignIndex {
|
||||
campaigns: Vec<Campaign>,
|
||||
}
|
||||
@@ -130,6 +142,7 @@ impl CampaignIndex {
|
||||
campaigns.push(Campaign {
|
||||
uuid: parse_ticket_field(&content, "ID"),
|
||||
title: heading_title(&content),
|
||||
codename: parse_codename(&content),
|
||||
content,
|
||||
});
|
||||
}
|
||||
@@ -250,6 +263,9 @@ impl Standing {
|
||||
|
||||
/// The campaign file as it is written.
|
||||
///
|
||||
/// The codename sits directly under the ID, because that is what it is: a second way to
|
||||
/// say which campaign this is, in a word rather than in thirty-six characters.
|
||||
///
|
||||
/// The same shape a ticket has, minus what a campaign has no use for: no acceptance
|
||||
/// criteria, because its definition of done is derived from its members rather than
|
||||
/// written down, no implementation plan, and no Status, because it sits in no status
|
||||
@@ -258,6 +274,7 @@ impl Standing {
|
||||
pub fn campaign_body(
|
||||
title: &str,
|
||||
description: &[String],
|
||||
codename: Option<&str>,
|
||||
id: &uuid::Uuid,
|
||||
owner: Option<&str>,
|
||||
created_at: &str,
|
||||
@@ -279,11 +296,17 @@ pub fn campaign_body(
|
||||
{metadata_heading}\n\
|
||||
\n\
|
||||
- **ID**: {id}\n\
|
||||
- **{codename_field}**: {codename}\n\
|
||||
- **Owner**: {owner}\n\
|
||||
- **Created At**: {created_at}\n\
|
||||
",
|
||||
description_heading = DESCRIPTION.heading,
|
||||
metadata_heading = METADATA_HEADING,
|
||||
owner = owner.unwrap_or("_Not set_"),
|
||||
codename_field = CODENAME_FIELD,
|
||||
// Written unset rather than left out, the way `add` writes an unset Due on every
|
||||
// ticket: the line is then there to read and there to edit by hand, and one shape
|
||||
// of file is one thing for the parser to be right about.
|
||||
codename = codename.unwrap_or(NOT_SET),
|
||||
owner = owner.unwrap_or(NOT_SET),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -109,6 +109,27 @@ fn iso_date(raw: &str) -> Result<String, String> {
|
||||
Ok(raw.to_string())
|
||||
}
|
||||
|
||||
/// Reject a codename that is not one word.
|
||||
///
|
||||
/// At parse time, like `iso_date` and `priority_level`, so a mistyped value is a usage
|
||||
/// error with nothing written. One word because the board draws it as a label beside the
|
||||
/// tags, with a mark and no quoting: `~beaver release` on that row reads as two labels, and
|
||||
/// the second one is not a campaign. A title is where a sentence goes.
|
||||
///
|
||||
/// Nothing else is checked. There is no registry of codenames to check against, the same
|
||||
/// reason `ls --tag` refuses to validate a tag, and a length limit would be a number
|
||||
/// invented here: a label the column will not hold is dropped whole by the row that draws
|
||||
/// it.
|
||||
fn codename(raw: &str) -> Result<String, String> {
|
||||
let value = non_empty(raw)?;
|
||||
|
||||
if value.split_whitespace().count() > 1 {
|
||||
return Err("codename must be a single word, for example v1 or beaver".to_string());
|
||||
}
|
||||
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
/// Arguments that carry prose, and therefore have to accept a value starting with
|
||||
/// a hyphen.
|
||||
///
|
||||
@@ -299,6 +320,9 @@ pub enum CampaignCommand {
|
||||
/// and no implementation plan. Priority, tags and a due date are left out because
|
||||
/// nothing reads them yet, and a field written but never shown is a field that goes
|
||||
/// stale unnoticed.
|
||||
///
|
||||
/// `--codename` is the exception to that last rule and earns it: the board draws it on
|
||||
/// every card in the campaign, and it exists because the uuid does not fit there.
|
||||
#[derive(clap::Args)]
|
||||
pub struct CampaignAddArgs {
|
||||
/// Campaign title
|
||||
@@ -309,6 +333,14 @@ pub struct CampaignAddArgs {
|
||||
#[arg(short, long, allow_hyphen_values = PROSE)]
|
||||
pub description: Vec<String>,
|
||||
|
||||
/// A single word to call the campaign by, for example v1 or beaver
|
||||
///
|
||||
/// The uuid is what every command stores and the title is a sentence, so neither is
|
||||
/// what a card has room to print. This is the short form the board draws, and it is
|
||||
/// optional: a campaign without one is drawn by its short id instead.
|
||||
#[arg(short, long, value_parser = codename)]
|
||||
pub codename: Option<String>,
|
||||
|
||||
/// Owner. Defaults to the git user
|
||||
#[arg(short, long)]
|
||||
pub owner: Option<String>,
|
||||
|
||||
+21
-2
@@ -1037,7 +1037,12 @@ pub fn cmd_relate(args: &RelateArgs, start: &Path) -> Result<()> {
|
||||
/// half-written campaign behind. `cmd_add` predates that primitive and still uses the
|
||||
/// plain write; the difference is noted on the ticket rather than fixed here.
|
||||
pub fn cmd_campaign_add(args: &CampaignAddArgs, start: &Path) -> Result<()> {
|
||||
let CampaignAddArgs { title, description, owner } = args;
|
||||
let CampaignAddArgs {
|
||||
title,
|
||||
description,
|
||||
codename,
|
||||
owner,
|
||||
} = args;
|
||||
|
||||
let worklane_dir = find_worklane_dir(start)?;
|
||||
let dir = ensure_campaigns_dir(&worklane_dir)?;
|
||||
@@ -1054,6 +1059,7 @@ pub fn cmd_campaign_add(args: &CampaignAddArgs, start: &Path) -> Result<()> {
|
||||
let body = campaign_body(
|
||||
title,
|
||||
description,
|
||||
codename.as_deref(),
|
||||
&id,
|
||||
owner.as_deref(),
|
||||
&Local::now().format(TIMESTAMP_FORMAT).to_string(),
|
||||
@@ -1099,9 +1105,22 @@ pub fn cmd_campaign_ls(worklane_dir: &Path, ids: bool) -> Result<()> {
|
||||
None => String::new(),
|
||||
};
|
||||
|
||||
// The codename between the id and the title, in the colour the board draws it in
|
||||
// and with the same mark: the answer to "which campaign is this" is one word, and
|
||||
// it should be the same word wherever it is read. A campaign filed without one
|
||||
// spends nothing on it, the way an untagged card spends no row.
|
||||
let codename = match campaign.codename.is_some() {
|
||||
true => {
|
||||
let label = campaign_label(&campaign.uuid, campaign.codename.as_deref());
|
||||
format!("{} ", paint_cells(&[label], colored))
|
||||
}
|
||||
false => String::new(),
|
||||
};
|
||||
|
||||
println!(
|
||||
" ({}) {} | {}{}",
|
||||
" ({}) {}{} | {}{}",
|
||||
paint(short_id(&campaign.uuid), Color::Red, colored),
|
||||
codename,
|
||||
campaign.title,
|
||||
standing.label(),
|
||||
state,
|
||||
|
||||
+14
-1
@@ -177,13 +177,22 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
|
||||
continue;
|
||||
}
|
||||
|
||||
// The same contract for the campaign picker, which is the other mode that owns
|
||||
// the keyboard while it is open. Two calls rather than one combined pre-branch,
|
||||
// because only one of the two can be open at a time and each reports for
|
||||
// itself; the rules are `Board::search_key` and `Board::picker_key`, where a
|
||||
// test can reach them.
|
||||
if board.picker_key(key, screen) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match key.code {
|
||||
// One arm, because the two keys mean one thing: close what is open, and
|
||||
// quit when there is nothing left to close. Two arms carrying one rule
|
||||
// is how a later edit changes it for one key and not the other, which is
|
||||
// what `q` quitting out from under an open ticket already was. The rule
|
||||
// itself is `Board::dismiss`, where a test can reach it.
|
||||
KeyCode::Esc | KeyCode::Char('q') => board.dismiss(),
|
||||
KeyCode::Esc | KeyCode::Char('q') => board.dismiss(screen),
|
||||
// The only key that leaves the board from an open ticket, which is why
|
||||
// the footer names it there.
|
||||
KeyCode::Char('c') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
@@ -215,6 +224,10 @@ fn run_tui(paths: &[std::path::PathBuf], start: &std::path::Path) -> Result<()>
|
||||
// left that a vim hand would reach for. The clipboard is handed in rather
|
||||
// than reached for inside `Board`, so the suite can drive both answers.
|
||||
KeyCode::Char('y') => board.copy_selected_id(clipboard::copy),
|
||||
// The way in to the campaign picker, like `/` is to the search prompt: from
|
||||
// the next keypress on `picker_key` above has the keyboard. Free of every
|
||||
// other binding, and `ctrl-c` is matched above this so quitting still wins.
|
||||
KeyCode::Char('c') => board.open_picker(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
+1472
-75
File diff suppressed because it is too large
Load Diff
+111
-8
@@ -389,14 +389,22 @@ fn status_paths(worklane_dir: &Path) -> Vec<(String, std::path::PathBuf)> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The three-tier search, run over `dirs`, returning the first tier that matched
|
||||
/// The four-tier search, run over `dirs`, returning the first tier that matched
|
||||
/// anything.
|
||||
///
|
||||
/// Three tiers, filled in one pass and consulted in order. A uuid prefix has to win
|
||||
/// Four tiers, filled in one pass and consulted in order. A uuid prefix has to win
|
||||
/// outright rather than join a flat list: ticket titles reference other tickets by id,
|
||||
/// so an exact prefix match was reported as ambiguous against whichever title happened
|
||||
/// to mention it.
|
||||
///
|
||||
/// **An exact codename wins over all three.** It is the one tier that is an exact match on
|
||||
/// a field written for the purpose, so it cannot be a coincidence the way a substring can,
|
||||
/// and a codename of `v1` is too short to be tried as an id at all. Only campaigns carry
|
||||
/// the field, so for a ticket the tier is always empty and resolution is exactly what it
|
||||
/// was. It lives here rather than in a campaign-only path for the reason the rest of this
|
||||
/// function is shared: that would be a second copy of the precedence rules and a second
|
||||
/// ambiguity message.
|
||||
///
|
||||
/// Shared by tickets and campaigns rather than written twice. A campaign is addressed
|
||||
/// exactly the way a ticket is, and a second resolver would be a second copy of the
|
||||
/// precedence rules to keep in step. Each entry pairs the name a match is reported
|
||||
@@ -405,6 +413,7 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
|
||||
let search_lower = search.to_lowercase();
|
||||
let long_enough_for_an_id = search.chars().count() >= MIN_ID_SEARCH;
|
||||
|
||||
let mut by_codename: Vec<Found> = Vec::new();
|
||||
let mut by_id: Vec<Found> = Vec::new();
|
||||
let mut by_title: Vec<Found> = Vec::new();
|
||||
let mut by_filename: Vec<Found> = Vec::new();
|
||||
@@ -429,12 +438,17 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
|
||||
.unwrap_or_default();
|
||||
let uuid = filename.split('_').next().unwrap_or("");
|
||||
|
||||
// Case insensitive like the other three: a codename typed back off a listing
|
||||
// has to resolve whatever case it was read in, which is the bargain the id
|
||||
// tier already takes.
|
||||
let is_codename = parse_codename(&content)
|
||||
.is_some_and(|codename| codename.to_lowercase() == search_lower);
|
||||
let by_prefix = long_enough_for_an_id && uuid.to_lowercase().starts_with(&search_lower);
|
||||
let in_title = title.to_lowercase().contains(&search_lower);
|
||||
// Still reaches the middle of a uuid, which the prefix tier cannot.
|
||||
let in_filename = filename.to_lowercase().contains(&search_lower);
|
||||
|
||||
if !(by_prefix || in_title || in_filename) {
|
||||
if !(is_codename || by_prefix || in_title || in_filename) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -444,7 +458,9 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
|
||||
content,
|
||||
uuid: uuid.to_string(),
|
||||
};
|
||||
if by_prefix {
|
||||
if is_codename {
|
||||
by_codename.push(found);
|
||||
} else if by_prefix {
|
||||
by_id.push(found);
|
||||
} else if in_title {
|
||||
by_title.push(found);
|
||||
@@ -454,10 +470,11 @@ pub fn resolve_in(search: &str, dirs: &[(String, std::path::PathBuf)]) -> Result
|
||||
}
|
||||
}
|
||||
|
||||
Ok(match (by_id.is_empty(), by_title.is_empty()) {
|
||||
(false, _) => by_id,
|
||||
(true, false) => by_title,
|
||||
(true, true) => by_filename,
|
||||
Ok(match (by_codename.is_empty(), by_id.is_empty(), by_title.is_empty()) {
|
||||
(false, _, _) => by_codename,
|
||||
(true, false, _) => by_id,
|
||||
(true, true, false) => by_title,
|
||||
(true, true, true) => by_filename,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -846,6 +863,13 @@ fn metadata_value_cell(name: &str, value: &str, colored: bool, campaign: &str) -
|
||||
return paint(value, Color::Grey, colored);
|
||||
}
|
||||
|
||||
// The same word in the same colour as the label a card draws, since `tag_color` is a
|
||||
// pure function of it. No mark here: the field name has already said what this is,
|
||||
// and the mark is what tells a campaign from a tag on a row that holds both.
|
||||
if name == CODENAME_FIELD {
|
||||
return paint(value, tag_color(value), colored);
|
||||
}
|
||||
|
||||
if name == "Tags" {
|
||||
return paint_tags(value, colored);
|
||||
}
|
||||
@@ -1133,6 +1157,66 @@ pub fn set_metadata_field(content: &str, field: &str, value: &str, title: &str)
|
||||
/// board.
|
||||
pub const CAMPAIGN_FIELD: &str = "Campaign";
|
||||
|
||||
/// The metadata field naming a campaign in a word, beside the uuid that addresses it.
|
||||
///
|
||||
/// A campaign is filed for a release or a migration, and those have names people already
|
||||
/// use: `v1`, `beaver`. The uuid is what everything stores and the title is a sentence, so
|
||||
/// neither is what a card has room to print. This is the short form, written by
|
||||
/// `campaign add --codename` and nothing else.
|
||||
///
|
||||
/// Optional, and a campaign without one is not a lesser campaign: every campaign filed
|
||||
/// before this existed has no field at all, which reads as unset the way an absent
|
||||
/// Campaign field does.
|
||||
pub const CODENAME_FIELD: &str = "Codename";
|
||||
|
||||
/// The mark a campaign carries where it is drawn as a label.
|
||||
///
|
||||
/// Not `#`, which is the tag marker: the two sit on the same row of a card and the row
|
||||
/// would read as one list of tags with a stranger in it. A tilde is ASCII, so it renders
|
||||
/// wherever `#` does, and it is not `@`, which reads as a person on every board anyone
|
||||
/// has used.
|
||||
///
|
||||
/// One glyph, so the campaign on a card and the campaign in the picker are the same
|
||||
/// thing said the same way.
|
||||
pub const CAMPAIGN_MARK: &str = "~";
|
||||
|
||||
/// The campaign codename a file names, or nothing when it names none.
|
||||
///
|
||||
/// Absent, unset and empty are one answer, the bargain [`parse_campaign`] and
|
||||
/// [`parse_tags`] both take: a campaign filed before the field existed carries no line at
|
||||
/// all, and one whose line reads `_Not set_` has no codename either.
|
||||
pub fn parse_codename(content: &str) -> Option<String> {
|
||||
let value = parse_ticket_field(content, CODENAME_FIELD);
|
||||
|
||||
match is_unknown_value(&value) || value.trim().is_empty() {
|
||||
true => None,
|
||||
false => Some(value.trim().to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
/// A campaign as a label: the mark, then the codename, or the short id when it has none.
|
||||
///
|
||||
/// The id is the fallback rather than the title, which is a sentence and would not fit the
|
||||
/// row this is drawn on. It says little, which is the whole reason the codename field
|
||||
/// exists, but it is addressable: `campaign show` takes it.
|
||||
///
|
||||
/// **A codename takes its own colour from [`tag_color`] and the fallback takes grey.** The
|
||||
/// colour is what groups a campaign across the cards that carry it, and one word is one
|
||||
/// colour in every view for the same reason a tag is. Grey on the id, rather than the red
|
||||
/// a uuid is drawn in everywhere else, keeps a reserved meaning off a `TAG_COLORS` slot in
|
||||
/// the one case where the label is an id: grey already means what a reader skips, which is
|
||||
/// what a campaign with no codename has to say for itself.
|
||||
///
|
||||
/// A `Cell`, not a string, so the CLI paints it and the board makes a span of it, the way
|
||||
/// a relation row already works. The bold is the board's: it is there to win a row against
|
||||
/// the tags, and nothing in the CLI shares a line with them.
|
||||
pub fn campaign_label(uuid: &str, codename: Option<&str>) -> Cell {
|
||||
match codename {
|
||||
Some(codename) => Cell::colored(format!("{CAMPAIGN_MARK}{codename}"), tag_color(codename)),
|
||||
None => Cell::colored(format!("{CAMPAIGN_MARK}{}", short_id(uuid)), Color::Grey),
|
||||
}
|
||||
}
|
||||
|
||||
/// The campaign uuid a ticket names, or nothing when it names none.
|
||||
///
|
||||
/// Absent and unset are the same answer: a ticket that has never been assigned has no
|
||||
@@ -1574,6 +1658,25 @@ fn section_body(lines: &[&str], heading: &str) -> Option<std::ops::Range<usize>>
|
||||
Some(after..section_end(lines, after))
|
||||
}
|
||||
|
||||
/// The first line of a section's body, or nothing when the section is absent or holds
|
||||
/// only its placeholder.
|
||||
///
|
||||
/// For a view with one row to spend on prose: the board's campaign frame and its picker
|
||||
/// both want the opening line of a description and have no room for the rest. Through
|
||||
/// [`section_body`] rather than a scan of its own, so what counts as the section is
|
||||
/// decided in one place, and the placeholder reads as nothing here the way it does to
|
||||
/// `append`.
|
||||
pub fn section_opening(content: &str, section: &Section) -> Option<String> {
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let body = section_body(&lines, section.heading)?;
|
||||
|
||||
lines[body]
|
||||
.iter()
|
||||
.map(|line| line.trim())
|
||||
.find(|line| !line.is_empty() && *line != section.placeholder)
|
||||
.map(|line| line.to_string())
|
||||
}
|
||||
|
||||
/// Where the body's content ends, ignoring the blank lines that separate it from
|
||||
/// whatever follows.
|
||||
fn body_content_end(lines: &[&str], body: &std::ops::Range<usize>) -> usize {
|
||||
|
||||
Reference in New Issue
Block a user