[squeak-dev] startup time command line (or dropped files)
arguments
Chris Muller
asqueaker at gmail.com
Wed Oct 1 01:42:13 UTC 2014
Don't "reel in horror" drama-boy. Squeak's command-line processing is
simple and effective. I use it heavily every day.
As you know, you can just pass in your arguments into 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.
Normally, the .st script would contain something like the following:
Smalltalk runAndQuit:
[ : 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.
I personally like the Smalltalk #run... API because it handles all the
Notifications, Warnings, SyntaxErrors and Errors the way I like (by
logging them to stdout and stderr) but you don't /have/ to use that if
you don't want. You can always check "Smalltalk argumentAt:
anInteger" to simply 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".
On Tue, Sep 30, 2014 at 1:12 PM, tim Rowledge <tim at rowledge.org> wrote:
> How are command line arguments intended for the image supposed to be dealt with these days? It’s an awfully long time since last I looked at this area and the code I’m seeing in the image is… convoluted.
>
> I need to be able to handle some simple cases for Scratch startup and we seem to have completely changed how that area is handled. I have come across (and reeled in horror) code in ProjectLauncher, AutoStart etc but so far I don’t see anything to make it all make sense in my head. I don’t suppose anybody knows of a correct wiki page? Not found one so far.
>
> Maybe I need to drop one or more of the current startup related classes and write a ScratchStart class?
>
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> Programmer: One who is too lacking in people skills to be a software engineer.
>
>
>
More information about the Squeak-dev
mailing list
|