(p Prompt, allowPreview, allowMetadata, allowDraft, isDraft bool)
| 53 | } |
| 54 | |
| 55 | func confirmSubmission(p Prompt, allowPreview, allowMetadata, allowDraft, isDraft bool) (Action, error) { |
| 56 | var options []string |
| 57 | if !isDraft { |
| 58 | options = append(options, submitLabel) |
| 59 | } |
| 60 | if allowDraft { |
| 61 | options = append(options, submitDraftLabel) |
| 62 | } |
| 63 | if allowPreview { |
| 64 | options = append(options, previewLabel) |
| 65 | } |
| 66 | if allowMetadata { |
| 67 | options = append(options, metadataLabel) |
| 68 | } |
| 69 | options = append(options, cancelLabel) |
| 70 | |
| 71 | result, err := p.Select("What's next?", "", options) |
| 72 | if err != nil { |
| 73 | return -1, fmt.Errorf("could not prompt: %w", err) |
| 74 | } |
| 75 | |
| 76 | switch options[result] { |
| 77 | case submitLabel: |
| 78 | return SubmitAction, nil |
| 79 | case submitDraftLabel: |
| 80 | return SubmitDraftAction, nil |
| 81 | case previewLabel: |
| 82 | return PreviewAction, nil |
| 83 | case metadataLabel: |
| 84 | return MetadataAction, nil |
| 85 | case cancelLabel: |
| 86 | return CancelAction, nil |
| 87 | default: |
| 88 | return -1, fmt.Errorf("invalid index: %d", result) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func BodySurvey(p Prompt, state *IssueMetadataState, templateContent string) error { |
| 93 | if templateContent != "" { |
no test coverage detected