appcli

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

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransformModeNone = iota
	TransformModeTrimSpace
	TransformModeCamelCase
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AskManyOpts

type AskManyOpts struct {
	Key           string
	Message       string
	Required      bool
	TransformMode TransformModeType
}

type AutocompleteFunc

type AutocompleteFunc func(toComplete string) []string

type SurveyWrap

type SurveyWrap struct {
}

SurveyWrap wraps the survey package

func (SurveyWrap) Ask

func (SurveyWrap) Ask(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error

Ask is a wrapper for the survey.Ask() func

func (SurveyWrap) AskOne

func (SurveyWrap) AskOne(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error

AskOne is a wrapper for the survey.AskOne() func

type SurveyWrapper

type SurveyWrapper interface {
	AskOne(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error
	Ask(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error
}

SurveyWrapper is a wrapper around the survey package. This makes the cli package unit testable.

type SwizCli

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

func (*SwizCli) Ask

func (l *SwizCli) Ask(prompt string, required bool) (string, error)

Ask asks a question

func (*SwizCli) AskAutocomplete

func (l *SwizCli) AskAutocomplete(prompt string, required bool, complete AutocompleteFunc) (string, error)

AskAutocomplete asks a question with autocomplete

func (*SwizCli) AskConfirm

func (l *SwizCli) AskConfirm(prompt string) (bool, error)

AskConfirm asks the user to confirm with Y/n

func (*SwizCli) AskMany

func (l *SwizCli) AskMany(prompts []AskManyOpts) (map[string]string, error)

AskMany asks many questions

func (*SwizCli) AskOptions

func (l *SwizCli) AskOptions(prompt string, options []string) (string, error)

AskOptions asks with a list of options

func (*SwizCli) Info

func (l *SwizCli) Info(format string, i ...interface{})

Info outputs an informational message

func (*SwizCli) Infoln

func (l *SwizCli) Infoln(i ...interface{})

Infoln outputs an informational message with a newline

type SwizClier

type SwizClier interface {
	Info(format string, i ...interface{})
	Infoln(i ...interface{})
	Ask(prompt string, required bool) (string, error)
	AskAutocomplete(prompt string, required bool, complete AutocompleteFunc) (string, error)
	AskConfirm(prompt string) (bool, error)
	AskOptions(prompt string, options []string) (string, error)
	AskMany(prompts []AskManyOpts) (map[string]string, error)
}

func NewCli

func NewCli(o io.Writer, i io.Reader) SwizClier

NewCli creates a new cli

type TransformModeType

type TransformModeType int

Jump to

Keyboard shortcuts

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