Use json to quote strings.

This commit is contained in:
Nuno Cruces 2022-05-05 13:03:53 +01:00
parent 17827d3b70
commit e34f649c02
2 changed files with 12 additions and 10 deletions

View file

@ -55,13 +55,13 @@ fmt.stringFromDate(date.dateValue)
var app=Application.currentApplication() var app=Application.currentApplication()
app.includeStandardAdditions=true app.includeStandardAdditions=true
app.activate() app.activate()
ObjC.import("stdlib") ObjC.import('stdio')
ObjC.import("stdio") ObjC.import('stdlib')
var opt={{json .Options}} var opts={{json .Options}}
{{- if .IconPath}} {{- if .IconPath}}
opt["withIcon"]=Path("{{.IconPath}}") opts.withIcon=Path({{json .IconPath}})
{{- end}} {{- end}}
var res=app.{{.Operation}}({{json .Text}},opt) var res=app.{{.Operation}}({{json .Text}},opts)
if(res.gaveUp){$.exit(5)} if(res.gaveUp){$.exit(5)}
if(res.buttonReturned==={{json .Extra}}){$.puts(res.buttonReturned) if(res.buttonReturned==={{json .Extra}}){$.puts(res.buttonReturned)
$.exit(1)} $.exit(1)}

View file

@ -2,13 +2,15 @@ var app = Application.currentApplication()
app.includeStandardAdditions = true app.includeStandardAdditions = true
app.activate() app.activate()
ObjC.import("stdlib") ObjC.import('stdio')
ObjC.import("stdio") ObjC.import('stdlib')
var opt = {{json .Options}}
var opts = {{json .Options}}
{{- if .IconPath}} {{- if .IconPath}}
opt["withIcon"] = Path("{{.IconPath}}") opts.withIcon = Path({{json .IconPath}})
{{- end}} {{- end}}
var res = app.{{.Operation}}({{json .Text}}, opt)
var res = app.{{.Operation}}({{json .Text}}, opts)
if (res.gaveUp) { if (res.gaveUp) {
$.exit(5) $.exit(5)
} }