Edit a campaign's description, and bump to 0.27.0
`campaign set` reached the title and the codename, so the description a campaign was filed with was the description it kept: fixing a typo in the one field nothing could edit meant a hand edit of the file, or refiling the campaign and reassigning every member. Both halves arrive together, which is why d637288 left this out rather than adding the flag. `campaign set --description` replaces the section and `campaign append --description` adds a paragraph to it, because a `set` with no `append` is the half that is easy to reach for and wrong: replacing a description to add a sentence is how the rest of it gets lost. `append` is a campaign's own subcommand rather than the top-level one, which resolves a ticket. `resolve_in`'s tiers are the same over both directories, so one positional naming either object could resolve in each with nothing but a flag to say which was meant, and it would make a liar of the explanation `resolve_ticket` gives a ticket search that names a campaign. The section is the `DESCRIPTION` entry and the surgery is `set_section_body`, `append_section_body` and `Section::normalise`, not a copy scoped to campaigns. `SECTION_ORDER` needs no campaign variant: a campaign holds one section where a ticket holds four, and the followers a campaign does not have are simply not in the file, so its description anchors against `## Metadata`, where `campaign_body` writes it. Still no `--clear`, and that is now a decision rather than a deferral: a campaign's description has no cleared form, so an empty `--description ""` is a paragraph break here as it is everywhere else, and the refusal for an all-blank value says there is nowhere to go back to instead of naming a flag that does not exist. `replaced_items` and `appended_items` hold that check once for both objects, with the way out as the caller's argument. The section refusal no longer says "Ticket", since a campaign reaches it too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
5dc087d49e
commit
3592584747
+8
-2
@@ -1843,6 +1843,12 @@ pub fn clear_section_body(content: &str, section: &Section) -> Result<String> {
|
||||
}
|
||||
|
||||
/// The line surgery both of the above are, given a body that is already rendered.
|
||||
///
|
||||
/// The refusal names the section and not the file it is missing from, because both a ticket
|
||||
/// and a campaign reach here: `campaign set --description` writes a campaign's one prose
|
||||
/// section through this, so "Ticket has no description section" would be wrong half the
|
||||
/// time. `write_then_replace` carries the noun instead, where a message about a *file* is
|
||||
/// worth spelling.
|
||||
fn replace_section_body(
|
||||
content: &str,
|
||||
section: &Section,
|
||||
@@ -1850,7 +1856,7 @@ fn replace_section_body(
|
||||
) -> Result<String> {
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let body = section_body(&lines, section.heading)
|
||||
.ok_or_else(|| anyhow!("Ticket has no {} section", section.label))?;
|
||||
.ok_or_else(|| anyhow!("There is no {} section to write to", section.label))?;
|
||||
|
||||
let mut out: Vec<String> = lines[..body.start].iter().map(|l| l.to_string()).collect();
|
||||
out.extend(body_lines);
|
||||
@@ -1871,7 +1877,7 @@ fn replace_section_body(
|
||||
pub fn append_section_body(content: &str, section: &Section, items: &[String]) -> Result<String> {
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let body = section_body(&lines, section.heading)
|
||||
.ok_or_else(|| anyhow!("Ticket has no {} section", section.label))?;
|
||||
.ok_or_else(|| anyhow!("There is no {} section to write to", section.label))?;
|
||||
|
||||
let at = body_content_end(&lines, &body);
|
||||
let existing: Vec<&&str> = lines[body.start..at]
|
||||
|
||||
Reference in New Issue
Block a user