editor

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CommandNoOp = ":"

CommandNoOp is a special command that indicates that no editor should be launched and the text should be returned as-is. This behavior is copied from git's GIT_EDITOR. https://github.com/git/git/blob/5699ec1b0aec51b9e9ba5a2785f65970c5a95d84/editor.c#L57

Variables

This section is empty.

Functions

func DefaultCommand

func DefaultCommand(repo *git.Repo) string

func Launch

func Launch(repo *git.Repo, config Config) (string, error)

Launch launches the user's editor and allows them to edit the text. The text is returned after the editor is closed. If an error occurs, the (possibly edited) text is returned in addition to the error. If the file could not be read, an empty string is returned.

Types

type Config

type Config struct {
	// The text to be edited.
	// After the editor is closed, the contents will be written back to this field.
	Text string
	// The file pattern to use when creating the temporary file for the editor.
	TmpFilePattern string
	// The prefix used to identify comments in the text.
	CommentPrefix string
	// If true, strip comments from the end of lines. If false, only whole lines
	// that are comments will be stripped.
	EndOfLineComments bool
	// The editor command to be used.
	// If empty, the git default editor will be used.
	Command string
}

Jump to

Keyboard shortcuts

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