MCPcopy
hub / github.com/cli/cli / MarkdownEditor

Method MarkdownEditor

internal/prompter/prompter.go:304–339  ·  view source on GitHub ↗
(prompt, defaultValue string, blankAllowed bool)

Source from the content-addressed store, hash-verified

302}
303
304func (p *accessiblePrompter) MarkdownEditor(prompt, defaultValue string, blankAllowed bool) (string, error) {
305 var result string
306 skipOption := "skip"
307 launchOption := "launch"
308 options := []huh.Option[string]{
309 huh.NewOption(fmt.Sprintf("Launch %s", surveyext.EditorName(p.editorCmd)), launchOption),
310 }
311 if blankAllowed {
312 options = append(options, huh.NewOption("Skip", skipOption))
313 }
314
315 form := p.newForm(
316 huh.NewGroup(
317 huh.NewSelect[string]().
318 Title(prompt).
319 Options(options...).
320 Value(&result),
321 ),
322 )
323
324 if err := form.Run(); err != nil {
325 return "", err
326 }
327
328 if result == skipOption {
329 return "", nil
330 }
331
332 // launchOption was selected
333 text, err := surveyext.Edit(p.editorCmd, "*.md", defaultValue, p.stdin, p.stdout, p.stderr)
334 if err != nil {
335 return "", err
336 }
337
338 return text, nil
339}
340
341func (p *accessiblePrompter) MultiSelectWithSearch(prompt, searchPrompt string, defaultValues, persistentValues []string, searchFunc func(string) MultiSelectSearchResult) ([]string, error) {
342 return multiSelectWithSearch(p, prompt, searchPrompt, defaultValues, persistentValues, searchFunc)

Callers

nothing calls this directly

Calls 7

newFormMethod · 0.95
EditorNameFunction · 0.92
EditFunction · 0.92
ValueMethod · 0.80
OptionsMethod · 0.80
TitleMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected