prompt

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package prompt provides functions for prompting decisions via the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Suggest

func Suggest(output io.Writer, suggestions ...Suggestion) error

Suggest zero or more actions to be taken by the user, writing the output to the provided io.Writer implementation.

func YesNo

func YesNo(input io.Reader, output io.Writer, format string, args ...interface{}) (bool, error)

YesNo writes a formatted message to output and waits for user input with either a y or n character. Any input other than a y will return false.

Types

type Suggestion

type Suggestion struct {
	Message string
	Command string
	Link    string
}

The Suggestion type represents a recommended action a user should take. It can either be a message but can also include a suggested command.

func NewSuggestion

func NewSuggestion(opts ...SuggestionOption) Suggestion

NewSuggestion creates a new Suggestion type and applies all SuggestionOption functions to it.

type SuggestionOption

type SuggestionOption func(a *Suggestion)

The SuggestionOption is a function that modifies the fields of a Suggestion.

func WithCommand

func WithCommand(format string, args ...interface{}) SuggestionOption

WithCommand sets the formatted command of a Suggestion.

func WithLink(url string) SuggestionOption

WithLink sets the link of a Suggestion for a user to navigate to.

func WithMessage

func WithMessage(format string, args ...interface{}) SuggestionOption

WithMessage sets the formatted message of a Suggestion.

Jump to

Keyboard shortcuts

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