editor

package
v0.18.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL