MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / prompt

Method prompt

pkg/surveyext/editor.go:64–197  ·  view source on GitHub ↗
(initialValue string, config *survey.PromptConfig)

Source from the content-addressed store, hash-verified

62}
63
64func (e *OctoEditor) prompt(initialValue string, config *survey.PromptConfig) (interface{}, error) {
65 // render the template
66 err := e.Render(
67 OctoEditorQuestionTemplate,
68 OctoEditorTemplateData{
69 Editor: *e.Editor,
70 Optional: e.Optional,
71 Config: config,
72 },
73 )
74 if err != nil {
75 return "", err
76 }
77
78 // start reading runes from the standard in
79 rr := e.NewRuneReader()
80 _ = rr.SetTermMode()
81 defer func() {
82 _ = rr.RestoreTermMode()
83 }()
84
85 cursor := e.NewCursor()
86 cursor.Hide()
87 defer cursor.Show()
88
89 for {
90 r, _, err := rr.ReadRune()
91 if err != nil {
92 return "", err
93 }
94 if (r == '\r' || r == '\n') && e.Optional {
95 e.skipped = true
96 return initialValue, nil
97 }
98 if r == 'e' {
99 break
100 }
101 if r == terminal.KeyInterrupt {
102 return "", terminal.InterruptErr
103 }
104 if r == terminal.KeyEndTransmission {
105 break
106 }
107 if string(r) == config.HelpInput && e.Help != "" {
108 err = e.Render(
109 OctoEditorQuestionTemplate,
110 OctoEditorTemplateData{
111 Editor: *e.Editor,
112 Optional: e.Optional,
113 ShowHelp: true,
114 Config: config,
115 },
116 )
117 if err != nil {
118 return "", err
119 }
120 }
121 continue

Callers 2

PromptAgainMethod · 0.95
PromptMethod · 0.95

Calls 2

CommandMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected