editor

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detect

func Detect() string

Detect the editor by looking into the KICKOFF_EDITOR, EDITOR and VISUAL environment variables. If none of these contains an editor command "vi" is used as a fallback.

Types

type Editor

type Editor struct {
	cli.IOStreams
	Command string
}

Editor can prompt a user to manipulate text by opening it with an editor.

func New

func New(streams cli.IOStreams) *Editor

New creates a new *Editor.

func (*Editor) Edit

func (e *Editor) Edit(contents []byte, pattern string) ([]byte, error)

Edit writes contents to a temporary file and opens it with an editor . A pattern (e.g. '*.yaml') can be provided to control the extension of the temporary file that is created and then opened with the editor. This is useful as a hint for the editor so that it can choose a suitable syntax highlighting. Returns the byte slice with the edited result after the user closed the editor.

Jump to

Keyboard shortcuts

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