MCPcopy Create free account
hub / github.com/cli/cli / confirmSubmission

Function confirmSubmission

pkg/cmd/pr/shared/survey.go:55–90  ·  view source on GitHub ↗
(p Prompt, allowPreview, allowMetadata, allowDraft, isDraft bool)

Source from the content-addressed store, hash-verified

53}
54
55func 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
92func BodySurvey(p Prompt, state *IssueMetadataState, templateContent string) error {
93 if templateContent != "" {

Callers 2

ConfirmIssueSubmissionFunction · 0.70
ConfirmPRSubmissionFunction · 0.70

Calls 2

SelectMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected