2020-01-21 07:03:58 -05:00
|
|
|
var app = Application.currentApplication()
|
|
|
|
app.includeStandardAdditions = true
|
|
|
|
app.activate()
|
|
|
|
|
2022-05-05 08:03:53 -04:00
|
|
|
ObjC.import('stdio')
|
|
|
|
ObjC.import('stdlib')
|
|
|
|
|
|
|
|
var opts = {{json .Options}}
|
2021-10-06 18:39:36 -04:00
|
|
|
{{- if .IconPath}}
|
2022-05-06 08:48:31 -04:00
|
|
|
opts.withIcon = Path({{json .IconPath}})
|
2021-10-06 18:39:36 -04:00
|
|
|
{{- end}}
|
2022-05-05 08:03:53 -04:00
|
|
|
|
2022-05-06 08:48:31 -04:00
|
|
|
try {
|
|
|
|
var res = app.{{.Operation}}({{json .Text}}, opts)
|
|
|
|
} catch (e) {
|
|
|
|
if (e.errorNumber === -128) $.exit(1)
|
|
|
|
$.dprintf(2, e)
|
|
|
|
$.exit(-1)
|
|
|
|
}
|
|
|
|
|
2020-01-28 07:46:43 -05:00
|
|
|
if (res.gaveUp) {
|
2022-05-06 08:48:31 -04:00
|
|
|
$.exit(5)
|
2020-01-28 07:46:43 -05:00
|
|
|
}
|
|
|
|
if (res.buttonReturned === {{json .Extra}}) {
|
2022-05-06 08:48:31 -04:00
|
|
|
$.puts(res.buttonReturned)
|
|
|
|
$.exit(1)
|
2021-03-04 21:01:59 -05:00
|
|
|
}
|
|
|
|
res.textReturned
|