utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2017 License: GPL-3.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FgBlack   = color.New(color.FgBlack).SprintFunc()
	FgRed     = color.New(color.FgRed).SprintFunc()
	FgGreen   = color.New(color.FgGreen).SprintFunc()
	FgYellow  = color.New(color.FgYellow).SprintFunc()
	FgBlue    = color.New(color.FgBlue).SprintFunc()
	FgMagenta = color.New(color.FgMagenta).SprintFunc()
	FgCyan    = color.New(color.FgCyan).SprintFunc()
	FgWhite   = color.New(color.FgWhite).SprintFunc()

	FgHiBlack   = color.New(color.FgHiBlack).SprintFunc()
	FgHiRed     = color.New(color.FgHiRed).SprintFunc()
	FgHiGreen   = color.New(color.FgHiGreen).SprintFunc()
	FgHiYellow  = color.New(color.FgHiYellow).SprintFunc()
	FgHiBlue    = color.New(color.FgHiBlue).SprintFunc()
	FgHiMagenta = color.New(color.FgHiMagenta).SprintFunc()
	FgHiCyan    = color.New(color.FgHiCyan).SprintFunc()
	FgHiWhite   = color.New(color.FgHiWhite).SprintFunc()

	BgBlack   = color.New(color.BgBlack).SprintFunc()
	BgRed     = color.New(color.BgRed).SprintFunc()
	BgGreen   = color.New(color.BgGreen).SprintFunc()
	BgYellow  = color.New(color.BgYellow).SprintFunc()
	BgBlue    = color.New(color.BgBlue).SprintFunc()
	BgMagenta = color.New(color.BgMagenta).SprintFunc()
	BgCyan    = color.New(color.BgCyan).SprintFunc()
	BgWhite   = color.New(color.BgWhite).SprintFunc()

	BgHiBlack   = color.New(color.BgHiBlack).SprintFunc()
	BgHiRed     = color.New(color.BgHiRed).SprintFunc()
	BgHiGreen   = color.New(color.BgHiGreen).SprintFunc()
	BgHiYellow  = color.New(color.BgHiYellow).SprintFunc()
	BgHiBlue    = color.New(color.BgHiBlue).SprintFunc()
	BgHiMagenta = color.New(color.BgHiMagenta).SprintFunc()
	BgHiCyan    = color.New(color.BgHiCyan).SprintFunc()
	BgHiWhite   = color.New(color.BgHiWhite).SprintFunc()
)

Terminal Colors

Functions

func AskForConfirmationMust

func AskForConfirmationMust(s string) bool

AskForConfirmationMust asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user.

func EnsureDirectoryExists

func EnsureDirectoryExists(path string) error

EnsureDirectoryExists ensures that path exists

func ExpandFilePath added in v0.5.0

func ExpandFilePath(p string) (xp string, err error)

ExpandFilePath takes a file path either containing environment variables and/or relative paths and expands it to the full path.

func GetDataDirectory

func GetDataDirectory() string

GetDataDirectory returns the default directory for storing user data

func GetFileExt added in v0.5.0

func GetFileExt(f string) string

GetFileExt returns the file's extension in lower case

func InSliceString

func InSliceString(i string, s []string) bool

InSliceString returns true if string i is in slice s

func PrintNoteColored

func PrintNoteColored(n *note.Note, titleOnly bool)

PrintNoteColored prints the Note to stdout in color

func PrintNotes

func PrintNotes(notes note.Notes, format string) error

PrintNotes prints notes in the given format

func PrintNotesCSV

func PrintNotesCSV(notes note.Notes) error

PrintNotesCSV prints Notes in csv format

func PrintNotesColored

func PrintNotesColored(notes note.Notes, titleOnly bool)

PrintNotesColored prints the list of Notes to stdout in color

func PrintNotesIDs

func PrintNotesIDs(notes note.Notes)

PrintNotesIDs prints the Note's ids

func PrintNotesJSON

func PrintNotesJSON(notes note.Notes) error

PrintNotesJSON prints Notes in json format

Types

type Editor

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

Editor provides an interface to open text editors and retrieve the text entered

func NewEditor

func NewEditor() (*Editor, error)

NewEditor returns a new Editor

func (*Editor) Close

func (e *Editor) Close()

Close closes the temp file and removes it

func (*Editor) Open

func (e *Editor) Open() error

Open opens a text editor specified by defaultEditor (overridden by editorEnvVariable) Than waits for it to close and saves the text that was entered.

func (*Editor) SetText

func (e *Editor) SetText(text string)

SetText sets the text to be opened in the Editor. This has no effect after the editor is opened

func (*Editor) Text

func (e *Editor) Text() string

Text returns the text the user entered in the editor

Jump to

Keyboard shortcuts

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