cli

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cli provides functionality for gathering text (which may or may not be potentially sensitive) by way of an interactive text editor.

Big thanks to: https://samrapdev.com/capturing-sensitive-input-with-editor-in-golang-from-the-cli/

Index

Constants

View Source
const DefaultEditor = "nano"

DefaultEditor is nano because I prefer it.

Variables

This section is empty.

Functions

func CaptureInputFromEditor

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

CaptureInputFromEditor 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 GetPreferredEditorFromEnvironment

func GetPreferredEditorFromEnvironment() string

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

func OpenFileInEditor

func OpenFileInEditor(filename string, resolveEditor PreferredEditorResolver) error

OpenFileInEditor opens filename in a text editor.

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