Image Command Line Options
Last updated at 1:38 am UTC on 2 October 2014
Squeak allows you to pass arguments to the image from the command-line like this:
squeak my.image arg1 arg2 arg3 &
Normally, "arg1" is the name of a .st script you would like to execute, while arg2 and arg3 are arguments to that script. This is useful when you want to give the image instructions from a file in the OS.
That .st script would contain something like the following:
[ : arg2 : arg3 | "Do something. arg2 and arg3 are the Strings from the command-line." ]
After executing the block, the image will exit without saving. That is useful for batch applications but if you want to launch a server or something interactive where the user invokes the exit, you could simply use Smalltalk #run: instead of #runAndQuit:. There may be another case where you want to "build" an image and want it to save. There's one for that too.
The Smalltalk #run... API it handles Notifications, Warnings, SyntaxErrors and Errors by logging them to stdout and stderr. It doesn't have to be used. To check arguments manually,
Smalltalk argumentAt: anInteger
can be used to obtain the command-line arguments as Strings.
There are advanced cases where you may not want the first argument to be the name of a script. For those you can unset preference "readDocumentAtStartup".