commandline

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AskMultipleChoice = func(question string, choices []string) string {
	selectedOption, _ := pterm.DefaultInteractiveSelect.
		WithDefaultText(question).
		WithOnInterruptFunc(func() {
			os.Exit(1)
		}).
		WithOptions(choices).
		Show()

	return selectedOption
}
View Source
var AskOpenEndedQuestion = func(question, defaultVal string, secret bool) string {
	var result string
	for {
		if secret {
			result, _ = pterm.DefaultInteractiveTextInput.
				WithDefaultText(question).
				WithMask("*").
				WithMultiLine(false).
				WithOnInterruptFunc(func() {
					os.Exit(1)
				}).
				Show()
		} else if defaultVal == "" {
			result, _ = pterm.DefaultInteractiveTextInput.
				WithDefaultText(question).
				WithMultiLine(false).
				WithOnInterruptFunc(func() {
					os.Exit(1)
				}).
				Show()
		} else {
			result, _ = pterm.DefaultInteractiveTextInput.
				WithDefaultText(question).
				WithDefaultValue(defaultVal).
				WithMultiLine(false).
				WithOnInterruptFunc(func() {
					os.Exit(1)
				}).
				Show()
		}

		if result != "" {
			break
		}

		fmt.Println("--- This question is required ---")
	}

	return result
}
View Source
var AskYesNoQuestion = func(question string) bool {
	result, _ := pterm.DefaultInteractiveConfirm.
		WithDefaultText(question).
		WithDefaultValue(true).
		WithOnInterruptFunc(func() {
			os.Exit(1)
		}).
		Show()

	return result
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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