-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathtell.go
32 lines (29 loc) · 1021 Bytes
/
tell.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
** Tell
** Tells an application commands.
*/
package mack
// Tell tells an application the specified commands
// mack.Tell("TextEdit", "activate") // Activates TextEdit
// mack.Tell("TextEdit", "quit") // Quits TextEdit
// mack.Tell("Finder",
// "activate",
// `open (POSIX file "/Applications")`) // Activate Finder and open the "/Applications" folder
//
// Parameters:
//
// application string // Required - What application the system will tell to
// commands string // Required - What command lines the system will tell
func Tell(application string, commands ...string) (string, error) {
return run(buildTell(application, commands...))
}
// Parse the Tell options and build the command
func buildTell(application string, commands ...string) string {
application = wrapInQuotes(application)
args := []string{"tell application", application, "\n"}
for _, command := range commands {
args = append(args, command, "\n")
}
args = append(args, "end", "tell")
return build(args...)
}