I want to be able to decompile and compile and AppleScript Script Library (scptd) with an Scripting Definition (sdef), so I can put the text source in version control.
The background of this question is to put my AppleScript sources in git
. Most of my questions have been answered by this stackoverflow question/answer, but my question described here is still preventing me from putting all my scripts in git.
In this library test.scptd
I have an handler with the name say it loud
, and in the sdef
file test.sdef
it is declared as a command with the code SAYTLOUD
.
When using osadecompile
, I get an AppleScript text file test.applescript
:
on say it loud whatToSay
do shell script "say " & quoted form of whatToSay
end on say it loud
However, this source can't be compiled with osacompile
, because the link to the sdef
file has been broken and say it loud
is not a valid identifier.
Luckily, I found the binary compile_as (source here), which is part of the excellent editor TextMate. When, decompiling, I get the following source file test_raw.applescript
:
on «event SAYTLOUD» whatToSay
do shell script "say " & quoted form of whatToSay
end «event SAYTLOUD»
This is what I want, because the code is still valid AppleScript and it's runnable. The only difference is you can't call the handler by name, but you need to use the raw code. No problems here.
My question: how do I compile the AppleScript file test_raw.applescript
(with the raw codes), combined with the test.sdef
file into an test.scptd
.
An obvious answer would be to create my own decompile_as
with Objective-C and OSAKit (if possible), but I do not posses the skills involved.