cliprompts

package module
v2.0.0-...-801ca03 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: Apache-2.0 Imports: 13 Imported by: 5

README

CliPrompts

This library isolates third-party CLI library dependencies from tooling such as NSC. While you are free to use this as you see fit, the use of this library is intended for tooling as is only supported as far as insuring that it works for tools where it is used.

License Apache 2 ReportCard

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bold

func Bold(s string) string

func Confirm

func Confirm(m string, value bool, o ...Opt) (bool, error)

func GetOutput

func GetOutput() io.Writer

func Italic

func Italic(s string) string

func MultiSelect

func MultiSelect(m string, choices []string, o ...Opt) ([]int, error)

func Open

func Open(url string) *exec.Cmd

func Password

func Password(m string, o ...Opt) (string, error)

func Prompt

func Prompt(label string, value string, o ...Opt) (string, error)

func ResetPromptLib

func ResetPromptLib()

func Select

func Select(m string, value string, choices []string, o ...Opt) (int, error)

func SetOutput

func SetOutput(out io.Writer)

func SetPromptLib

func SetPromptLib(p PromptLib)

func Underline

func Underline(s string) string

func Wrap

func Wrap(lim uint, args ...interface{}) string

func WrapSprintf

func WrapSprintf(lim uint, format string, a ...interface{}) string

func WrapString

func WrapString(lim uint, s string) string

Types

type Logger

type Logger func(args ...interface{})
var LogFn Logger

set a Logger during a test (cli.LogFn = t.Log) to debug interactive prompts

type Opt

type Opt func(o *Opts)

func Help

func Help(h string) Opt

func NewEmailValidator

func NewEmailValidator() Opt

func NewLengthValidator

func NewLengthValidator(min int) Opt

func NewPathOrURLValidator

func NewPathOrURLValidator() Opt

func NewURLValidator

func NewURLValidator(protocol ...string) Opt

func Val

func Val(fn Validator) Opt

type Opts

type Opts struct {
	Help string
	Fn   Validator
}

type PromptLib

type PromptLib interface {
	Prompt(label string, value string, opt ...Opt) (string, error)
	Confirm(m string, defaultValue bool, o ...Opt) (bool, error)
	Password(m string, o ...Opt) (string, error)
	Select(m string, value string, choices []string, o ...Opt) (int, error)
	MultiSelect(m string, choices []string, o ...Opt) ([]int, error)
}

func NewTestPrompts

func NewTestPrompts(inputs []interface{}) PromptLib

type SurveyUI

type SurveyUI struct{}

func (*SurveyUI) Confirm

func (sui *SurveyUI) Confirm(m string, defaultValue bool, o ...Opt) (bool, error)

func (*SurveyUI) MultiSelect

func (sui *SurveyUI) MultiSelect(m string, choices []string, o ...Opt) ([]int, error)

func (*SurveyUI) Password

func (sui *SurveyUI) Password(m string, o ...Opt) (string, error)

func (*SurveyUI) Prompt

func (sui *SurveyUI) Prompt(label string, value string, o ...Opt) (string, error)

func (*SurveyUI) Select

func (sui *SurveyUI) Select(m string, value string, choices []string, o ...Opt) (int, error)

type TestPrompts

type TestPrompts struct {
	// contains filtered or unexported fields
}

func (*TestPrompts) Confirm

func (t *TestPrompts) Confirm(m string, v bool, o ...Opt) (bool, error)

func (*TestPrompts) MultiSelect

func (t *TestPrompts) MultiSelect(m string, choices []string, o ...Opt) ([]int, error)

func (*TestPrompts) Password

func (t *TestPrompts) Password(m string, o ...Opt) (string, error)

func (*TestPrompts) Prompt

func (t *TestPrompts) Prompt(label string, value string, o ...Opt) (string, error)

func (*TestPrompts) Select

func (t *TestPrompts) Select(m string, value string, choices []string, o ...Opt) (int, error)

type Validator

type Validator func(string) error

func EmailValidator

func EmailValidator() Validator

func LengthValidator

func LengthValidator(min int) Validator

func PathOrURLValidator

func PathOrURLValidator() Validator

func URLValidator

func URLValidator(protocol ...string) Validator

Jump to

Keyboard shortcuts

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