editor

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package editor was sourced from this article and then updated: https://samrapdev.com/capturing-sensitive-input-with-editor-in-golang-from-the-cli

Index

Constants

View Source
const DefaultEditor = "vi"

DefaultEditor will always fall back to vi

Variables

This section is empty.

Functions

func CaptureInput

func CaptureInput(resolveEditor PreferredEditorResolver) ([]byte, error)

CaptureInput opens a temporary file in a text editor and returns the written bytes on success or an error on failure. It handles deletion of the temporary file behind the scenes.

func OpenFile

func OpenFile(filename string, resolveEditor PreferredEditorResolver) error

OpenFile opens filename in a text editor

func PreferredEditor

func PreferredEditor() string

PreferredEditor returns the user's editor as defined by the `$EDITOR` environment variable, or the `DefaultEditor` if it is not set.

Types

type PreferredEditorResolver

type PreferredEditorResolver func() string

PreferredEditorResolver is a function that returns an editor that the user prefers to use, such as the configured `$EDITOR` environment variable.

Jump to

Keyboard shortcuts

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