| 409 | Lines below dotted lines will be ignored, and an empty title aborts the creation process.` |
| 410 | |
| 411 | func TitledEditSurvey(editor Editor) func(string, string) (string, string, error) { |
| 412 | return func(initialTitle, initialBody string) (string, string, error) { |
| 413 | initialValue := strings.Join([]string{initialTitle, initialBody, editorHintMarker, editorHint}, "\n") |
| 414 | titleAndBody, err := editor.Edit("*.md", initialValue) |
| 415 | if err != nil { |
| 416 | return "", "", err |
| 417 | } |
| 418 | |
| 419 | titleAndBody = strings.ReplaceAll(titleAndBody, "\r\n", "\n") |
| 420 | titleAndBody, _, _ = strings.Cut(titleAndBody, editorHintMarker) |
| 421 | title, body, _ := strings.Cut(titleAndBody, "\n") |
| 422 | return title, strings.TrimSuffix(body, "\n"), nil |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | func InitEditorMode(f *cmdutil.Factory, editorMode bool, webMode bool, canPrompt bool) (bool, error) { |
| 427 | if err := cmdutil.MutuallyExclusive( |