WIP: progress (macOS).

This commit is contained in:
Nuno Cruces 2021-04-14 15:18:56 +01:00
parent 18f3259540
commit 02bbc4741c

View file

@ -0,0 +1,37 @@
var app = Application.currentApplication()
app.includeStandardAdditions = true
app.activate()
ObjC.import('stdlib')
ObjC.import('readline')
function run(args) {
Progress.totalUnitCount = 100
Progress.completedUnitCount = 0
Progress.description = args[0] || "Progress"
Progress.additionalDescription = args[1] || "Running..."
while (true) {
var s
try {
s = $.readline('')
}
catch (e) {
if (e.errorNumber === -128) $.exit(1)
break
}
if (s.indexOf('#') === 0) {
Progress.additionalDescription = s.slice(1).trim()
continue
}
var i = parseInt(s)
if (Number.isSafeInteger(i)) {
Progress.completedUnitCount = i
continue
}
}
Progress.completedUnitCount = 100
}