surveyext

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DatePickerQuestionTemplate = `` /* 537-byte string literal not displayed */
View Source
var OctoEditorQuestionTemplate = `` /* 696-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

type DatePickerAnswer struct {
	Time time.Time
}

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 OctoEditorTemplateData struct {
	survey.Editor
	Optional   bool
	Answer     string
	ShowAnswer bool
	ShowHelp   bool
	Config     *survey.PromptConfig
}

Jump to

Keyboard shortcuts

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