templates

package
v0.0.0-...-392efe7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTemplateName = gitmojiCommandTemplateName

DefaultTemplateName is the name of the template to use if when no template is specified.

View Source
var TemplateLookup = make(map[string]CommandTemplate, 2)

TemplateLookup maps template names to templates.

Functions

func GetTemplateMessage

func GetTemplateMessage(tpl CommandTemplate) string

GetTemplateMessage prompts the user for the teamplate prompts and then returns the result of formatting the "Messages" into a string.

func LoadTemplates

func LoadTemplates(ts map[string]interface{})

LoadTemplates reads a map of template names to basic data types and populates TemplateLookup with the result.

func RunTemplateCommand

func RunTemplateCommand(tpl CommandTemplate)

RunTemplateCommand prompts the user for the template prompts and then runs the command specified in the template.

Types

type CommandTemplate

type CommandTemplate struct {
	Prompts     []Prompt
	Command     string
	CommandArgs []string
	Messages    []string
}

CommandTemplate represents a command to execute and user prompts to get the command arguments.

type Prompt

type Prompt struct {
	Type      string         `yaml:"Type"`
	Mandatory bool           `yaml:"Mandatory,omitempty"`
	Prompt    string         `yaml:"Prompt,omitempty"`
	Name      string         `yaml:"Name"`
	Condition string         `yaml:"Condition,omitempty"`
	Choices   []PromptChoice `yaml:"Choices,omitempty"`
}

Prompt defines a question to ask the user.

type PromptChoice

type PromptChoice struct {
	Value       string `yaml:"Value"`
	Description string `yaml:"Description"`
}

PromptChoice defines a single option in a multiple-choice prompt.

Jump to

Keyboard shortcuts

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