editor

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Editor

type Editor struct {
	// contains filtered or unexported fields
}

Editor represents the external editor.

func NewEditor

func NewEditor(logger *slog.Logger, command, tmpDir string) *Editor

NewEditor instantiates a new editor with the desired command and temporary directory.

func (*Editor) Edit

func (e *Editor) Edit(payload []byte) (file.Interface, error)

Edit edits the informed payload on a temporary file, using the external editor.

func (*Editor) GetCommand

func (e *Editor) GetCommand() string

GetCommand shows the editor command.

func (*Editor) GetTmpDir

func (e *Editor) GetTmpDir() string

GetTmpDir exposes the temporary directory location.

type FakeEditor

type FakeEditor struct {
	// contains filtered or unexported fields
}

func NewFakeEditor

func NewFakeEditor(payload []byte) *FakeEditor

func (*FakeEditor) Edit

func (e *FakeEditor) Edit([]byte) (file.Interface, error)

func (*FakeEditor) GetCommand

func (*FakeEditor) GetCommand() string

func (*FakeEditor) GetTmpDir

func (*FakeEditor) GetTmpDir() string

type Interface

type Interface interface {
	// GetCommand shows the Editor command in use.
	GetCommand() string

	// GetTmpDir shows the temporary directory in use.
	GetTmpDir() string

	// Edit edits the payload using the external editor.
	Edit([]byte) (file.Interface, error)
}

Jump to

Keyboard shortcuts

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