packageconfigimport("fmt""io""os""strings""gopkg.in/yaml.v3")// Config is a tmpl configtypeConfigstruct{Prompts[]Prompt`yaml:"prompts"`}// PromptType is a type of prompttypePromptTypestringconst(PromptTypeInputPromptType="input"PromptTypeMultilinePromptType="multi"PromptTypeEditorPromptType="editor"PromptTypeConfirmPromptType="confirm"PromptTypeSelectPromptType="select")// Prompt is a tmpl prompttypePromptstruct{IDstring`yaml:"id"`Labelstring`yaml:"label"`Helpstring`yaml:"help"`Defaultstring`yaml:"default"`Options[]string`yaml:"options"`TypePromptType`yaml:"type"`}// Load loads a tmpl configfuncLoad(rio.Reader)(*Config,error){configBytes,err:=io.ReadAll(r)iferr!=nil{returnnil,err}configContents:=os.Expand(string(configBytes),func(sstring)string{ifstrings.HasPrefix(s,"TMPL_PROMPT"){returnfmt.Sprintf("${%s}",s)}returnos.Getenv(s)})varcConfigreturn&c,yaml.Unmarshal([]byte(configContents),&c)}