zenity/internal/zenutil/osascripts/file.gojs

31 lines
638 B
Text
Raw Normal View History

2020-01-04 22:21:39 -05:00
var app = Application.currentApplication()
app.includeStandardAdditions = true
app.activate()
var opts = {}
2020-01-14 20:04:06 -05:00
{{if .Prompt -}}
2020-01-21 07:03:58 -05:00
opts.withPrompt = {{json .Prompt}}
2020-01-14 20:04:06 -05:00
{{end -}}
2020-01-04 22:21:39 -05:00
{{if .Type -}}
2020-01-21 07:03:58 -05:00
opts.ofType = {{json .Type}}
2020-01-04 22:21:39 -05:00
{{end -}}
2020-01-06 07:01:51 -05:00
{{if .Name -}}
2020-01-21 07:03:58 -05:00
opts.defaultName = {{json .Name}}
2020-01-06 07:01:51 -05:00
{{end -}}
{{if .Location -}}
2020-01-21 07:03:58 -05:00
opts.defaultLocation = {{json .Location}}
2020-01-06 07:01:51 -05:00
{{end -}}
2020-01-14 20:04:06 -05:00
{{if .Invisibles -}}
2020-01-21 07:03:58 -05:00
opts.invisibles = {{json .Invisibles}}
2020-01-14 20:04:06 -05:00
{{end -}}
{{if .Multiple -}}
2020-01-21 07:03:58 -05:00
opts.multipleSelectionsAllowed = {{json .Multiple}}
2020-01-14 20:04:06 -05:00
{{end -}}
2020-01-04 22:21:39 -05:00
2020-01-21 07:03:58 -05:00
var res = app[{{json .Operation}}](opts)
2020-01-04 22:21:39 -05:00
if (Array.isArray(res)) {
2020-01-21 07:03:58 -05:00
res.join({{json .Separator}})
2020-01-04 22:21:39 -05:00
} else {
2020-01-06 07:01:51 -05:00
res.toString()
2020-01-04 22:21:39 -05:00
}