func (tr *templateRunner) Run(yamlData string, defaultVariables map[string]string) (string, error) {
	template, err := tr.parseYaml(yamlData)
	if err != nil {
		return "", err
	}
	variables := []keyValue{}
	for k, v := range defaultVariables {
		variables = append(variables, keyValue{Key: k, Value: v})
	}
	for _, environmentVariable := range template.Env {
		variables = append(variables, keyValue{Key: environmentVariable, Value: os.Getenv(environmentVariable)})
	}
	promptVariables := tr.prompt(template, variables)
	variables = append(variables, promptVariables...)
	message := tr.parseTemplate(template.Template, variables)
	return message, err
}
Run return the result of run the template
package templaterunner
import (
	"errors"
	"os"
	"regexp"
	"strings"
	"gopkg.in/yaml.v2"
)
type templateRunner struct {
	promptManager PromptManager
}
type PromptManager interface {
	ReadValue(title string, errorMessage string, defaultValue string) string
	ReadValueFromList(title string, options []Options) string
}
type TemplateRunner interface {
	Run(yamlData string, injectedVariables map[string]string) (message string, err error)
}
type Template struct {
	Env      []string     `yaml:"ENV"`
	Prompt   []PromptItem `yaml:"PROMPT"`
	Template string       `yaml:"TEMPLATE"`
}
type PromptItem struct {
	Key          string    `yaml:"KEY"`
	Label        string    `yaml:"LABEL"`
	ErrorLabel   string    `yaml:"ERROR_LABEL"`
	DefaultValue string    `yaml:"DEFAULT_VALUE"`
	Regex        string    `yaml:"REGEX"`
	Options      []Options `yaml:"OPTIONS"`
}
type Options struct {
	Value       string `yaml:"VALUE"`
	Description string `yaml:"DESC"`
}
type keyValue struct {
	Key   string
	Value string
}
func NewTemplateRunner(promptManager PromptManager) TemplateRunner {
	return &templateRunner{
		promptManager: promptManager,
	}
}
func (tr *templateRunner) parseYaml(yamlData string) (Template, error) {
	template := Template{}
	err := yaml.Unmarshal([]byte(yamlData), &template)
	if err != nil {
		return Template{}, errors.New("parsing yaml error")
	}
	return template, nil
}