add a way to add arbitrary plist contents

This commit is contained in:
2025-05-03 14:53:51 -04:00
parent 8405a8d01b
commit c56d5058ec
4 changed files with 87 additions and 2 deletions

13
main.go
View File

@@ -29,6 +29,7 @@ func run() error {
version = flag.String("version", "1.0", "app version")
identifier = flag.String("id", "", "bundle identifier")
icon = flag.String("icon", "", "icon image file (.icns|.png|.jpg|.jpeg)")
extraPlist = flag.String("plist", "", "path to file with additional plist dict key/value items")
)
flag.Parse()
args := flag.Args()
@@ -70,6 +71,13 @@ func run() error {
if id == "" {
id = *author + "." + *name
}
if *extraPlist != "" {
b, err := os.ReadFile(*extraPlist)
if err != nil {
return errors.Wrap(err, "error reading plist location: "+*extraPlist)
}
*extraPlist = string(b)
}
info := infoListData{
Name: *name,
Executable: filepath.Join("MacOS", appname),
@@ -77,6 +85,7 @@ func run() error {
Version: *version,
InfoString: *name + " by " + *author,
ShortVersionString: *version,
AdditionalPList: *extraPlist,
}
if *icon != "" {
iconPath, err := prepareIcons(*icon, resouresPath)
@@ -150,6 +159,7 @@ type infoListData struct {
InfoString string
ShortVersionString string
IconFile string
AdditionalPList string
}
const infoPlistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
@@ -176,6 +186,9 @@ const infoPlistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
<key>CFBundleIconFile</key>
<string>{{ .IconFile }}</string>
{{- end }}
{{- if .AdditionalPList -}}
{{ .AdditionalPList -}}
{{- end }}
</dict>
</plist>
`