editor

package
v0.32.8 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

Editor

This editor package is an adaptation of the kubectl editor package and its dependencies.

Original source: https://github.com/kubernetes/kubectl/tree/master/pkg/cmd/util/editor

LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Editor

type Editor struct {
	Args  []string
	Shell bool
}

Editor holds the command-line args to fire up the editor.

func NewDefaultEditor

func NewDefaultEditor(envs []string) Editor

NewDefaultEditor creates a struct Editor that uses the OS environment to locate the editor program, looking at EDITOR environment variable to find the proper command line. If the provided editor has no spaces, or no quotes, it is treated as a bare command to be loaded. Otherwise, the string will be passed to the user's shell for execution.

func (Editor) Launch

func (e Editor) Launch(path string) error

Launch opens the described or returns an error. The TTY will be protected, and SIGQUIT, SIGTERM, and SIGINT will all be trapped.

func (Editor) LaunchTempFile

func (e Editor) LaunchTempFile(prefix, suffix string, r io.Reader) ([]byte, string, error)

LaunchTempFile reads the provided stream into a temporary file in the given directory and file prefix, and then invokes Launch with the path of that file. It will return the contents of the file after launch, any errors that occur, and the path of the temporary file so the caller can clean it up as needed.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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