Documentation
¶
Overview ¶
Package editor encapsulates working with external text editor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EditFile = func(ctx context.Context, file string) error { editor, editorArgs := getEditorCommand() var args []string args = append(args, editorArgs...) args = append(args, file) cmd := exec.Command(editor, args...) cmd.Stderr = os.Stderr cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout log(ctx).Debugf("launching editor %q on file %q", editor, file) err := cmd.Run() if err != nil { return errors.Wrap(err, "error running editor command") } return nil }
EditFile launches the OS-specific editor (VI, notepad.exe or another editor configured through environment variables) to edit the specified file and waits for it to complete.
Functions ¶
func EditLoop ¶
func EditLoop(ctx context.Context, fname, initial string, withComments bool, parse func(updated string) error) error
EditLoop launches OS-specific editor (VI, notepad.exe or another editor configured through environment variables) It creates a temporary file with 'initial' contents and repeatedly invokes the editor until the provided 'parse' function returns nil result indicating success. The 'parse' function is passed the contents of edited files without # line comments.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.