cliprompts

package module
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

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 Italic

func Italic(s string) string

func Open

func Open(url string) *exec.Cmd

func Prompt

func Prompt(label string, value string, edit bool, validator Validator) (string, error)

func PromptBoolean

func PromptBoolean(m string, defaultValue bool) (bool, error)

func PromptChoices

func PromptChoices(m string, value string, choices []string) (int, error)

func PromptMultipleChoices

func PromptMultipleChoices(m string, choices []string) ([]int, error)

func PromptSecret

func PromptSecret(m string) (string, error)

func PromptWithHelp

func PromptWithHelp(label string, value string, edit bool, validator Validator, help string) (string, error)

func PromptYN

func PromptYN(m string) (bool, error)

func ResetPromptLib

func ResetPromptLib()

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 PromptLib

type PromptLib interface {
	Prompt(label string, value string, edit bool, validator Validator) (string, error)
	PromptWithHelp(label string, value string, edit bool, validator Validator, help string) (string, error)
	PromptYN(m string, defaultValue bool) (bool, error)
	PromptSecret(m string) (string, error)
	PromptChoices(m string, value string, choices []string) (int, error)
	PromptMultipleChoices(m string, choices []string) ([]int, error)
}

func NewTestPrompts

func NewTestPrompts(inputs []interface{}) PromptLib

type SurveyUI

type SurveyUI struct{}

func (*SurveyUI) Prompt

func (sui *SurveyUI) Prompt(label string, value string, edit bool, validator Validator) (string, error)

func (*SurveyUI) PromptChoices

func (sui *SurveyUI) PromptChoices(m string, value string, choices []string) (int, error)

func (*SurveyUI) PromptMultipleChoices

func (sui *SurveyUI) PromptMultipleChoices(m string, choices []string) ([]int, error)

func (*SurveyUI) PromptSecret

func (sui *SurveyUI) PromptSecret(m string) (string, error)

func (*SurveyUI) PromptWithHelp

func (sui *SurveyUI) PromptWithHelp(label string, value string, edit bool, validator Validator, help string) (string, error)

func (*SurveyUI) PromptYN

func (sui *SurveyUI) PromptYN(m string, defaultValue bool) (bool, error)

type TestPrompts

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

func (*TestPrompts) Prompt

func (t *TestPrompts) Prompt(label string, value string, edit bool, validator Validator) (string, error)

func (*TestPrompts) PromptChoices

func (t *TestPrompts) PromptChoices(m string, value string, choices []string) (int, error)

func (*TestPrompts) PromptMultipleChoices

func (t *TestPrompts) PromptMultipleChoices(m string, choices []string) ([]int, error)

func (*TestPrompts) PromptSecret

func (t *TestPrompts) PromptSecret(m string) (string, error)

func (*TestPrompts) PromptWithHelp

func (t *TestPrompts) PromptWithHelp(label string, value string, edit bool, validator Validator, help string) (string, error)

func (*TestPrompts) PromptYN

func (t *TestPrompts) PromptYN(m string, defaultValue bool) (bool, 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