forked from blek/bshchk
1
0
Fork 0
bshchk/template.go

35 lines
499 B
Go
Raw Permalink Normal View History

2024-06-02 11:32:17 +02:00
package main
import (
"bytes"
_ "embed"
"strings"
"text/template"
)
//go:embed rdc.sh
var bin string
type Template struct {
DepsVar string
Deps string
UnsetDeps bool
}
func gencode(deps []string) string {
2024-07-30 18:39:11 +02:00
if len(deps) == 0 {
return ""
}
2024-06-02 11:32:17 +02:00
rdc := Template{args.DepsVarName, "'" + strings.Join(deps, "' '") + "'", !args.ExposeDeps}
tmpl, err := template.New("").Parse(bin)
if err != nil {
panic(err)
}
var buf bytes.Buffer
tmpl.Execute(&buf, rdc)
return buf.String()
}