MacOS – way to make `open -a` pass command line arguments to the app it launches

command linemacosterminal

I'd like to run OpenSCAD from the command line with some arguments.

$ open -a openscad myfile.scad

works as I expect.

$ open -a openscad --args --help

reports

LSOpenURLsWithRole() failed for the application /Applications/OpenSCAD.app with error -10810.

when OpenSCAD is not already running. When OpenSCAD is already running, then open -a openscad --args --help simply brings OpenSCAD to the foreground.

What I really need is for this to work:

$ open -a openscad --args -o myfile.stl myfile.scad

which works just like my previous example. What should I do to launch OpenSCAD with command line arguments?

Before hitting submit I reproduced my questions for pasting here, and I found a solution that more-or-less works. All of these seem to do what I expect, even if OpenSCAD is not already running.

$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD --help
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD --args --help
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -o ball.stl ball.scad
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD --args -o ball.stl ball.scad

Still, is there a way to make open -a pass command line arguments to the app it launches?

Best Answer

The only thing I can get to work is opening a file. It seems that the App is not made to accept the args this way.

open -a openscad --args '/path/to/foo.scad'

The App does have an Applescript scripting definition but it only has reload defined.