plister

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 4 Imported by: 12

README

go-plister Build Status Coverage Status

A simple Apple Property List generator

Usage
package app

import (
	"log"
	"os"
	
	"github.com/sam-kamerer/go-plister"
)

var dict = map[string]interface{}{
    "CFBundlePackageType":     "APPL",
    "CFBundleInfoDictionaryVersion": "6.0",
    "CFBundleIconFile":        "icon.icns",
    "CFBundleDisplayName":     "Best App",
    "CFBundleExecutable":      "app_binary",
    "CFBundleName":            "BestApp",
    "CFBundleIdentifier":      "com.company.BestApp",
    "LSUIElement":             "NO",
    "LSMinimumSystemVersion":  "10.11",
    "NSHighResolutionCapable": true,
    "NSAppTransportSecurity": map[string]interface{}{
        "NSAllowsArbitraryLoads": true,
    },
    "CFBundleURLTypes": []map[string]interface{}{
        {
            "CFBundleTypeRole":   "Viewer",
            "CFBundleURLName":    "com.developer.testapp",
            "CFBundleURLSchemes": []interface{}{"testappscheme"},
        }, {
            "CFBundleTypeRole":   "Reader",
            "CFBundleURLName":    "com.developer.testapp",
            "CFBundleURLSchemes": []interface{}{"testappscheme-read"},
        },
    },
}

func main() {
    infoPlist := plister.MapToInfoPlist(dict)
    if err := plister.Generate("path/to/Info.plist", infoPlist); err != nil {
    	log.Fatal(err)
    }
    
    // or
    
    if err := plister.GenerateFromMap("path/to/Info.plist", dict); err != nil {
    	log.Fatal(err)
    }
    
    // or
    
    fp, err := os.Open("path/to/Info.plist")
    if err != nil {
    	log.Fatal(err)
    }
    if err := plister.Fprint(fp, infoPlist); err != nil {
    	log.Fatal(err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fprint

func Fprint(w io.Writer, data *InfoPlist) error

func Generate

func Generate(path string, data *InfoPlist) error

func GenerateFromMap

func GenerateFromMap(path string, data map[string]interface{}) error

Types

type Array added in v1.2.0

type Array struct {
	String []string `xml:"string"`
}

type Dict

type Dict struct {
	XMLName xml.Name `xml:"dict"`
	Items   []*DictItem
}

type DictItem

type DictItem struct {
	Key   string
	Value interface{}
}

func (DictItem) MarshalXML

func (di DictItem) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type InfoPlist

type InfoPlist struct {
	XMLName xml.Name `xml:"plist"`
	Version string   `xml:"version,attr"`
	Dict    *Dict
}

func MapToInfoPlist

func MapToInfoPlist(m map[string]interface{}) *InfoPlist

func Parse added in v1.2.0

func Parse(path string) (*InfoPlist, error)

func (*InfoPlist) Delete added in v1.2.0

func (ip *InfoPlist) Delete(key string)

func (*InfoPlist) Get

func (ip *InfoPlist) Get(key string) interface{}

func (*InfoPlist) Set

func (ip *InfoPlist) Set(key string, value interface{})

type Slice added in v1.1.0

type Slice struct {
	XMLName xml.Name      `xml:"array"`
	Items   []interface{} `xml:"string"`
}

type SliceDict added in v1.1.0

type SliceDict struct {
	XMLName xml.Name `xml:"dict"`
	Items   []*Dict
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL