28 lines
No EOL
522 B
Text
28 lines
No EOL
522 B
Text
var app = Application.currentApplication()
|
|
app.includeStandardAdditions = true
|
|
app.activate()
|
|
|
|
ObjC.import('stdio')
|
|
ObjC.import('stdlib')
|
|
|
|
var opts = {{json .Options}}
|
|
{{- if .IconPath}}
|
|
opts.withIcon = Path({{json .IconPath}})
|
|
{{- end}}
|
|
|
|
try {
|
|
var res = app.{{.Operation}}({{json .Text}}, opts)
|
|
} catch (e) {
|
|
if (e.errorNumber === -128) $.exit(1)
|
|
$.dprintf(2, e)
|
|
$.exit(-1)
|
|
}
|
|
|
|
if (res.gaveUp) {
|
|
$.exit(5)
|
|
}
|
|
if (res.buttonReturned === {{json .Extra}}) {
|
|
$.puts({{json .Extra}})
|
|
$.exit(1)
|
|
}
|
|
res.textReturned |