Documentation
¶
Index ¶
- func Confirm(args ...interface{}) (bool, error)
- func ConfirmFile(pathname string, args ...interface{}) (bool, error)
- func Confirmf(format string, args ...interface{}) (bool, error)
- func Debug(args ...interface{})
- func EditFile(pathname, notice, instructions string) ([]string, error)
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func InteractivityFlagSet() *pflag.FlagSet
- func Must(err error)
- func Must2[T any](v T, err error) T
- func OpenURL(s string) bool
- func Print(args ...interface{})
- func PrintWithCaller(args ...interface{})
- func Printf(format string, args ...interface{})
- func PrintfWithCaller(format string, args ...interface{})
- func Prompt(args ...interface{}) (string, error)
- func PromptFile(pathname string, args ...interface{}) (string, error)
- func Promptf(format string, args ...interface{}) (string, error)
- func PromptfFile(pathname, format string, args ...interface{}) (string, error)
- func Quiet()
- func Spin(args ...interface{})
- func Spinf(format string, args ...interface{})
- func Stop(args ...interface{})
- func StopErr(err error) error
- func Stopf(format string, args ...interface{})
- type InteractivityLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfirmFile ¶
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 EditFile ¶
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 InteractivityFlagSet ¶
func OpenURL ¶
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 PrintWithCaller ¶
func PrintWithCaller(args ...interface{})
func PrintfWithCaller ¶
func PrintfWithCaller(format string, args ...interface{})
func PromptFile ¶
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 PromptfFile ¶
PromptfFile is like PromptFile but allows formatting of the prompt.
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