Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DatePickerQuestionTemplate = `` /* 537-byte string literal not displayed */
var OctoEditorQuestionTemplate = `` /* 696-byte string literal not displayed */
var SelectQuestionTemplate = `` /* 1033-byte string literal not displayed */
Functions ¶
This section is empty.
Types ¶
type DatePicker ¶ added in v0.2.1
type DatePicker struct {
survey.Renderer
Message string
Default time.Time
Min time.Time
Max time.Time
Help string
AnswerFormatter func(*DatePicker, time.Time) string
OverrideNow time.Time // for unit testing; lets you override the definition of 'now'
// contains filtered or unexported fields
}
DatePicker is a prompt that presents a date/time picker. Response type is a time.Time
selectedTime := time.Time{}
prompt := &surveyext.DatePicker {
Message: "Choose a date and time:",
Default: time.Now(),
}
survey.AskOne(prompt, &selectedTime)
func (*DatePicker) Cleanup ¶ added in v0.2.1
func (d *DatePicker) Cleanup(config *survey.PromptConfig, val interface{}) error
func (*DatePicker) Error ¶ added in v0.2.1
func (d *DatePicker) Error(*survey.PromptConfig, error) error
func (*DatePicker) Now ¶ added in v0.2.1
func (d *DatePicker) Now() time.Time
Now returns the OverrideNow property (if it is set), else time.Now()
func (*DatePicker) Prompt ¶ added in v0.2.1
func (d *DatePicker) Prompt(config *survey.PromptConfig) (interface{}, error)
type DatePickerAnswer ¶ added in v0.2.1
DatePickerAnswer exists to workaround a survey bug (unintented code path?) where if the answer is a struct it thinks you're asking multiple questions and collecting the answers into struct fields. If you do this:
var answer time.Time
err = asker(&surveyext.DatePicker{ Message: "When?" }, &answer)
then the code in survey Write.go sees that the answer is a struct, and tries to go putting the response value into a named field on that struct (which doesn't exist). Workaround is to have a response-holder structure that implements survey.core.Settable
func (*DatePickerAnswer) WriteAnswer ¶ added in v0.2.1
func (a *DatePickerAnswer) WriteAnswer(_ string, value interface{}) error
type DatePickerTemplateData ¶ added in v0.2.1
type DatePickerTemplateData struct {
DatePicker
RawInput string // this is full of ansi escape sequences... It'd be nice to have survey's template thing render this, TODO attempt that later
Answer string
ShowAnswer bool
ShowHelp bool
SelectedComponent componentIdx
Config *survey.PromptConfig
}
type OctoEditor ¶
type OctoEditor struct {
*survey.Editor
Optional bool
// contains filtered or unexported fields
}
func (*OctoEditor) Cleanup ¶
func (e *OctoEditor) Cleanup(config *survey.PromptConfig, val interface{}) error
func (*OctoEditor) Prompt ¶
func (e *OctoEditor) Prompt(config *survey.PromptConfig) (interface{}, error)
func (*OctoEditor) PromptAgain ¶
func (e *OctoEditor) PromptAgain(config *survey.PromptConfig, invalid interface{}, err error) (interface{}, error)
type OctoEditorTemplateData ¶
type Select ¶ added in v0.5.0
type Select struct {
survey.Renderer
Message string
Options []string
Default interface{}
Help string
PageSize int
VimMode bool
FilterMessage string
Filter func(filter string, value string, index int) bool
Description func(value string, index int) string
// contains filtered or unexported fields
}
Select is a prompt that presents a list of various options to the user for them to select using the arrow keys and enter. Response type is a string.
color := ""
prompt := &survey.Select{
Message: "Choose a color:",
Options: []string{"red", "blue", "green"},
}
survey.AskOne(prompt, &color)
type SelectTemplateData ¶ added in v0.5.0
type SelectTemplateData struct {
Select
PageEntries []core.OptionAnswer
SelectedIndex int
Answer string
ShowAnswer bool
ShowHelp bool
Description func(value string, index int) string
Config *survey.PromptConfig
// These fields are used when rendering an individual option
CurrentOpt core.OptionAnswer
CurrentIndex int
}
SelectTemplateData is the data available to the templates when processing
func (SelectTemplateData) GetDescription ¶ added in v0.5.0
func (s SelectTemplateData) GetDescription(opt core.OptionAnswer) string
func (SelectTemplateData) IterateOption ¶ added in v0.5.0
func (s SelectTemplateData) IterateOption(ix int, opt core.OptionAnswer) interface{}
IterateOption sets CurrentOpt and CurrentIndex appropriately so a select option can be rendered individually