confirm

package
v0.0.0-...-6c7f99c Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package confirm provides an interface to ask a user to confirm an action. The user is provided with an interface to choose an affirmative or negative answer, which is then reflected in the exit code for use in scripting.

If the user selects the affirmative answer, the program exits with 0. If the user selects the negative answer, the program exits with 1.

I.e. confirm if the user wants to delete a file

$ gum confirm "Are you sure?" && rm file.txt

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Default     bool         `help:"Default confirmation action" default:"true"`
	Affirmative string       `help:"The title of the affirmative action" default:"Yes"`
	Negative    string       `help:"The title of the negative action" default:"No"`
	Prompt      string       `arg:"" help:"Prompt to display." default:"Are you sure?"`
	PromptStyle style.Styles `embed:"" prefix:"prompt." help:"The style of the prompt" set:"defaultMargin=1 0 0 0" envprefix:"GUM_CONFIRM_PROMPT_"`
	//nolint:staticcheck
	SelectedStyle style.Styles `` /* 206-byte string literal not displayed */
	//nolint:staticcheck
	UnselectedStyle style.Styles  `` /* 212-byte string literal not displayed */
	Timeout         time.Duration `help:"Timeout until confirm returns selected value or default if provided" default:"0" env:"GUM_CONFIRM_TIMEOUT"`

	utils.Result

	AsAPI bool // 是否以 API 的方式调用,非(GUM 本身的方式),不会直接 print,或者 exit
}

Options is the customization options for the confirm command.

func (*Options) Confirm

func (o *Options) Confirm(prompt string) (string, error)

Confirm API方式确认

func (*Options) Run

func (o *Options) Run() error

Run provides a shell script interface for prompting a user to confirm an action with an affirmative or negative answer.

Jump to

Keyboard shortcuts

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