confirmationPrompt asks once for every artifact, naming each one, such as "Delete artifacts 2 (OAuth callback plan) and 5 (Barista feedback notes) from monalisa/monas-cafe#142?".
(lookups []lookup, issueRef string)
| 190 | // "Delete artifacts 2 (OAuth callback plan) and 5 (Barista feedback notes) |
| 191 | // from monalisa/monas-cafe#142?". |
| 192 | func confirmationPrompt(lookups []lookup, issueRef string) string { |
| 193 | artifacts := make([]string, 0, len(lookups)) |
| 194 | for _, l := range lookups { |
| 195 | artifacts = append(artifacts, fmt.Sprintf("%d (%s)", l.number, l.name)) |
| 196 | } |
| 197 | noun := "artifact" |
| 198 | if len(artifacts) > 1 { |
| 199 | noun = "artifacts" |
| 200 | } |
| 201 | return fmt.Sprintf("Delete %s %s from %s?", noun, joinList(artifacts), issueRef) |
| 202 | } |
| 203 | |
| 204 | // joinList joins items the way the prompt reads them: "a", "a and b", or |
| 205 | // "a, b, and c". |