Documentation
¶
Overview ¶
Package sdef parses macOS scripting definition (sdef) XML and generates AppleScript runners from the parsed definitions.
Index ¶
- func AppName(appPath string) string
- func BuildScript(appName, cmdName, directParam string, params map[string]string) string
- func GetPropertyScript(appName, objectExpr, propName string) string
- func RunScript(script string) (string, error)
- func ToolName(appName, cmdName string) string
- type Class
- type Command
- type Dictionary
- type Element
- type Parameter
- type Property
- type Result
- type Suite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppName ¶
AppName returns a short display name for an app path (e.g. "Xcode" from "/Applications/Xcode.app").
func BuildScript ¶
BuildScript constructs an AppleScript tell-block for a command invocation. appName is the AppleScript application name (e.g. "Xcode"). cmdName is the AppleScript command (e.g. "build"). params is a map of parameter-name → value string. directParam is the direct parameter value (empty string = omit).
func GetPropertyScript ¶
GetPropertyScript returns an AppleScript to get a property of the application.
Types ¶
type Class ¶
type Class struct {
Name string `xml:"name,attr"`
Code string `xml:"code,attr"`
Description string `xml:"description,attr"`
Inherits string `xml:"inherits,attr"`
Properties []Property `xml:"property"`
Elements []Element `xml:"element"`
}
Class is a scriptable object class.
type Command ¶
type Command struct {
Name string `xml:"name,attr"`
Code string `xml:"code,attr"`
Description string `xml:"description,attr"`
Hidden string `xml:"hidden,attr"`
DirectParameter *Parameter `xml:"direct-parameter"`
Parameters []Parameter `xml:"parameter"`
Result *Result `xml:"result"`
}
Command is a scriptable command.
type Dictionary ¶
type Dictionary struct {
Suites []Suite `xml:"suite"`
}
Dictionary is the top-level sdef document.
func Parse ¶
func Parse(appPath string) (*Dictionary, error)
Parse runs sdef on appPath and returns the parsed Dictionary.
func (*Dictionary) Classes ¶
func (d *Dictionary) Classes() []Class
Classes returns all classes across all suites.
func (*Dictionary) Commands ¶
func (d *Dictionary) Commands() []Command
Commands returns all non-hidden commands across all suites.
type Parameter ¶
type Parameter struct {
Name string `xml:"name,attr"`
Code string `xml:"code,attr"`
Type string `xml:"type,attr"`
Optional string `xml:"optional,attr"`
Description string `xml:"description,attr"`
}
Parameter is a named command parameter.
type Property ¶
type Property struct {
Name string `xml:"name,attr"`
Code string `xml:"code,attr"`
Type string `xml:"type,attr"`
Access string `xml:"access,attr"`
Description string `xml:"description,attr"`
}
Property is a readable/writable attribute of a class.