如何使用脚本定义(sdef)编译AppleScript脚本库(scptd) [英] How to compile an AppleScript Script Library (scptd) with an Scripting Definition (sdef)

查看:165
本文介绍了如何使用脚本定义(sdef)编译AppleScript脚本库(scptd)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用脚本定义(sdef)进行反编译和AppleScript脚本库(scptd),以便将文本源置于版本控制中.

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.

此问题的背景是将我的AppleScript源码放入git中. 这个stackoverflow问题/答案已经回答了我的大多数问题,但是这里描述的问题仍然使我无法解决所有问题.我在git中的脚本.

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.

在这个库test.scptd中,我有一个名称为say it loud的处理程序,在sdef文件test.sdef中,它被声明为带有代码SAYTLOUD的命令.

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.

使用osadecompile时,我得到一个AppleScript文本文件test.applescript:

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

但是,该源不能使用osacompile进行编译,因为指向sdef文件的链接已断开,并且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.

幸运的是,我找到了二进制文件 compile_as (此处来源),这是出色的编辑器TextMate.反编译时,得到以下源文件test_raw.applescript:

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»

这就是我想要的,因为代码仍然是有效的AppleScript并且可以运行.唯一的区别是您不能按名称调用处理程序,但是您需要使用原始代码.没问题.

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.

我的问题:我如何编译 AppleScript文件test_raw.applescript(带有原始代码),再将test.sdef文件合并为test.scptd.

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.

一个明显的答案是使用Objective-C和OSAKit创建自己的decompile_as(如果可能),但是我不具备所涉及的技能.

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.

推荐答案

理想的解决方案是将.scptd捆绑包直接放入git存储库,然后对整个批次进行点火.

The ideal solution is to put your .scptd bundles directly into your git repository, then set fire to the whole lot.

第二好的解决方案是将.scptd捆绑包直接放入git存储库,然后编写位于git客户端和实际diff命令之间的自己的'diff'shell脚本(

The second-best solution is to put your .scptd bundles directly into your git repository, then write your own 'diff' shell script that sits between your git client and your actual diff command (example). When the shim script receives files with .scptd suffixes, pass them to osadecompile and write the output to temp text files, then pass those file paths to your diff tool. That'll give you human-readable diffs without having to break AppleScript's (inherently scm-hostile) file formats. Won't help if you want to do merges as well, obviously, but that's between you and your elder gods.

这篇关于如何使用脚本定义(sdef)编译AppleScript脚本库(scptd)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆