2022-06-01 19:00:08 -04:00
|
|
|
{{template "common" .}}
|
2022-05-11 12:49:15 -04:00
|
|
|
ObjC.import('stdio')
|
|
|
|
ObjC.import('stdlib')
|
|
|
|
|
|
|
|
var opts = {{json .Options}}
|
|
|
|
{{- if .IconPath}}
|
|
|
|
opts.withIcon = Path({{json .IconPath}})
|
|
|
|
{{- end}}
|
|
|
|
|
|
|
|
function dialog(text) {
|
|
|
|
try {
|
|
|
|
var res = app.displayDialog(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)
|
|
|
|
}
|
|
|
|
return res.textReturned
|
|
|
|
}
|
|
|
|
|
|
|
|
var start = Date.now()
|
|
|
|
opts.defaultAnswer = ''
|
|
|
|
var username = dialog('Username:')
|
|
|
|
|
|
|
|
{{- if .Options.Timeout}}
|
|
|
|
opts.givingUpAfter -= (Date.now() - start) / 1000 |0
|
|
|
|
{{- end}}
|
|
|
|
|
|
|
|
opts.hiddenAnswer = true
|
|
|
|
var password = dialog('Password:')
|
|
|
|
|
|
|
|
username + {{json .Separator}} + password
|