AIR command line arguments
I've been working on the next release of the Dojo Toolbox - which is an Adobe AIR app, using the Dojo Toolkit. I'm taking a TDD kind of approach to get on a better footing for evolving this thing, and needed a quick way to run a particular set of unit tests. I wanted to be able to do something like this:
$ adl runTests.xml testModule=toolbox.tests.SomeThingGetting command line arguments in AIR is via the invoke event, it looks something like this:
air.NativeApplication.nativeApplication.addEventListener(
air.InvokeEvent.INVOKE, function(evt){
window.scriptArgs = getScriptArgs(evt);
}
)
...But when I tried it, I just got a console error:
initial content not foundIt turns out that command line arguments to an AIR application are expected to be filenames - like if you dropped a file onto the app's icon. To pass through parameters and switches you first need
--
, like so:
$ adl runTests.xml -- testModule=toolbox.tests.allThe event your handler is passed has an arguments array property, and from there its straightforward to process what you've got to do the right thing. I'll get more into how I'm doing the unit tests in another post, but as this took a little digging I thought I'd share.
Labels: workish dojo air testing