zenity/internal/zenutil/osascripts/dialog.gojs
2022-05-09 15:50:25 +01:00

28 lines
No EOL
525 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(res.buttonReturned)
$.exit(1)
}
res.textReturned