Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit b916a31

Browse files
committed
Add AppleScript object
1 parent b19f8d6 commit b916a31

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

config/applescript.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package config
2+
3+
import "github.com/fatih/structs"
4+
5+
// AppleScript is an Alfred action that runs NSAppleScript
6+
type AppleScript struct {
7+
Cache bool `yaml:"cache" structs:"cachescript"`
8+
Script ScriptConfig `yaml:"script" structs:"-"`
9+
}
10+
11+
func (a AppleScript) ToWorkflowConfig() map[string]interface{} {
12+
m := structs.Map(a)
13+
m["applescript"] = a.Script.Content
14+
return m
15+
}

config/object.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
type ObjectType string
1414

1515
var (
16+
AppleScriptType ObjectType = "applescript"
1617
ClipboardType ObjectType = "clipboard"
1718
KeywordType ObjectType = "keyword"
1819
OpenURLType ObjectType = "open-url"
@@ -62,6 +63,12 @@ func (o *Object) UnmarshalYAML(node *yaml.Node) error {
6263
}
6364

6465
switch o.Type {
66+
case AppleScriptType:
67+
var cfg AppleScript
68+
if err := yaml.Unmarshal(rawConfig, &cfg); err != nil {
69+
return err
70+
}
71+
o.Config = cfg
6572
case ClipboardType:
6673
var cfg Clipboard
6774
if err := yaml.Unmarshal(rawConfig, &cfg); err != nil {
@@ -100,6 +107,7 @@ func (o *Object) UnmarshalYAML(node *yaml.Node) error {
100107
}
101108

102109
var objectType = map[ObjectType]string{
110+
"applescript": "alfred.workflow.action.applescript",
103111
"clipboard": "alfred.workflow.output.clipboard",
104112
"keyword": "alfred.workflow.input.keyword",
105113
"open-url": "alfred.workflow.action.openurl",

0 commit comments

Comments
 (0)