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