ui

package
v0.0.0-...-82ab749 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(args ...interface{}) (bool, error)

func ConfirmFile

func ConfirmFile(pathname string, args ...interface{}) (bool, error)

ConfirmFile wraps Confirm in ReadFile and os.WriteFile to avoid interactivity on subsequent invocations. If pathname exists, its contents (chomped) will be taken as the confirmation. If not, the confirmation given is written to pathname with a trailing newline and a notice is printed instructing the user to commit that file to version control.

func Confirmf

func Confirmf(format string, args ...interface{}) (bool, error)

func Debug

func Debug(args ...interface{})

func EditFile

func EditFile(pathname, notice, instructions string) ([]string, error)

EditFile guides a user to edit a plaintext file to provide input. If the file exists, it is first read and the user is offered the opportunity to accept it without modification via the notice argument to this function. If the file doesn't exist, or the user asks to edit its contents, their EDITOR (or vim, as a default) is opened and they're given instructions via the instructions argument to this function. After the file's written and the editor exits, the file is read once more and its final contents is returned as a slice of strings, each representing a line in the file (without the trailing newline).

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func InteractivityFlagSet

func InteractivityFlagSet() *pflag.FlagSet

func Must

func Must(err error)

func Must2

func Must2[T any](v T, err error) T

func OpenURL

func OpenURL(s string) bool

OpenURL opens u in a browser (or other appropriate app depending on the scheme and local configuration) and returns true or falls back to printing the URL with instructions to open it and returns false.

func Print

func Print(args ...interface{})

func PrintWithCaller

func PrintWithCaller(args ...interface{})

func Printf

func Printf(format string, args ...interface{})

func PrintfWithCaller

func PrintfWithCaller(format string, args ...interface{})

func Prompt

func Prompt(args ...interface{}) (string, error)

func PromptFile

func PromptFile(pathname string, args ...interface{}) (string, error)

PromptFile wraps Prompt in ReadFile and os.WriteFile to avoid prompting at all on subsequent invocations. If pathname exists, its contents (chomped) will be taken as the response to the prompt. If not, the response to the prompt is written to pathname with a trailing newline and a notice is printed instructing the user to commit that file to version control.

func Promptf

func Promptf(format string, args ...interface{}) (string, error)

func PromptfFile

func PromptfFile(pathname, format string, args ...interface{}) (string, error)

PromptfFile is like PromptFile but allows formatting of the prompt.

func Quiet

func Quiet()

func Spin

func Spin(args ...interface{})

func Spinf

func Spinf(format string, args ...interface{})

func Stop

func Stop(args ...interface{})

func StopErr

func StopErr(err error) error

StopErr calls Stop with either the error code from the given non-nil error as an argument or with the string "ok" otherwise.

func Stopf

func Stopf(format string, args ...interface{})

Types

type InteractivityLevel

type InteractivityLevel int
const (
	NonInteractive InteractivityLevel = iota
	MinimallyInteractive
	FullyInteractive
)

InteractivityLevel constants are ordered such that ordering comparisons make as much sense as equality comparisons.

func Interactivity

func Interactivity() InteractivityLevel

Jump to

Keyboard shortcuts

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