generate plist from filetypes and inject into app bundle
This commit is contained in:
58
filetypes/cmd/gen.go
Normal file
58
filetypes/cmd/gen.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"git.yetaga.in/alazyreader/why/filetypes"
|
||||
)
|
||||
|
||||
func main() {
|
||||
tpl, err := template.New("template").Parse(tmpl)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fplist, err := os.Create("documentTypes.plist")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
defer fplist.Close()
|
||||
if err := tpl.Execute(fplist, filetypes.Valid); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var tmpl = `
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>{{ range . }}
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>{{ range .MacExtensions }}
|
||||
<string>{{ . }}</string>{{ end }}
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>{{ .IconFile }}</string>
|
||||
<key>CFBundleTypeMIMETypes</key>
|
||||
<array>{{ range .MIMETypes }}
|
||||
<string>{{ . }}</string>{{ end }}
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>{{ .TypeName }}</string>
|
||||
<key>CFBundleTypeOSTypes</key>
|
||||
<array>{{ range .OSTypes }}
|
||||
<string>{{ . }}</string>{{ end }}
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>{{ .ItemContentTypes }}</string>
|
||||
</array>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<false/>
|
||||
</dict>{{ end }}
|
||||
`
|
Reference in New Issue
Block a user