gquiz

package module
v0.0.0-...-9910672 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: Apache-2.0 Imports: 6 Imported by: 3

README

gquiz

this is a lib to provide one way to do the wizard in yaml format.

Documentation

Index

Constants

View Source
const (
	Root = "root"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CandidateAnswer

type CandidateAnswer struct {
	Value       string `yaml:"value"`
	Description string `yaml:"description"`
}

type QGraph

type QGraph struct {
	QNodes []QNode
}

func (QGraph) FindNode

func (qg QGraph) FindNode(name string) *QNode

func (QGraph) FindRootNode

func (qg QGraph) FindRootNode() *QNode

type QNode

type QNode struct {
	Name        string       `yaml:"name"`
	Questions   []Question   `yaml:"questions,omitempty"`
	Transitions []Transition `yaml:"transitions"`
}

QNode sample: name: root questions:

  • var_name: kind description: "Which kind of artifacts do you want?" candidates:
  • value: infrastructure description: "To deployment the infrastructures, like: kubernetes..."
  • value: application description: "To deploy your application with code, like: php, java..."

transitions:

  • name: infrastructure condition: "kind == 'infrastructure'"
  • name: application condition: "kind == 'application'"

type QResult

type QResult map[string]string

type Question

type Question struct {
	VarName       string            `yaml:"var_name"`
	Type          string            `yaml:"type"`
	Description   string            `yaml:"description"`
	Candidates    []CandidateAnswer `yaml:"candidates,omitempty"`
	Default       string            `yaml:"default"`
	DefaultEnv    string            `yaml:"default_env"`
	Persistent    bool              `yaml:"persistent"`
	ConstantValue string            `yaml:"constant_value"`
}

type QuizBuilder

type QuizBuilder struct {
}

func (QuizBuilder) BuildQGraph

func (qb QuizBuilder) BuildQGraph(content []byte) (QGraph, error)

type QuizExecutor

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

func NewQuizExecutor

func NewQuizExecutor(ui UI, qr QResult) *QuizExecutor

func (*QuizExecutor) Execute

func (qe *QuizExecutor) Execute(qGraph *QGraph) (QResult, error)

func (*QuizExecutor) HandleNode

func (qe *QuizExecutor) HandleNode(qNode *QNode) (string, error)

HandleNode will return the next node name.

func (*QuizExecutor) HandleQuestion

func (qe *QuizExecutor) HandleQuestion(q *Question) (string, error)

type Transition

type Transition struct {
	Name      string `yaml:"name"`
	Condition string `yaml:"condition"`
}

type UI

type UI interface {
	Println(message string)
	GetInput() string
}

Jump to

Keyboard shortcuts

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