Launching class form command line ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Launching class form command line ...

jamesl
Hi All,

How does Pharo execute classes from the command line?

Is there a way to specify the class and the method to be called?
Are command line arguments available?

I want to put the same mechanism in Redline Smalltalk.

Rgs, James.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

Lukas Renggli
> How does Pharo execute classes from the command line?

You can pass the filename of a .cs/.st file to the VM that gets
filed-in on startup.

> Is there a way to specify the class and the method to be called?

Not directly.

> Are command line arguments available?

$ squeak --help
Usage: squeak [<option>...] [<imageName> [<argument>...]]
       squeak [<option>...] -- [<argument>...]

FBDev <option>s:
  -fbdev <dev>          use framebuffer device <dev> (default: /dev/fb)
  -kbmap <file>         load keymap from <file> (default: use kernel keymap)
  -msdev <dev>          use mouse device <dev> (default: /dev/psaux)
  -msproto <protocol>   use the given <protocol> for the mouse (default: ps2)
  -vtlock               disallow all vt switching (for any reason)
  -vtswitch             enable keyboard vt switching (Alt+FNx)

Common <option>s:
  -encoding <enc>       set the internal character encoding (default: MacRoman)
  -help                 print this help message, then exit
  -memory <size>[mk]    use fixed heap size (added to image size)
  -mmap <size>[mk]      limit dynamic heap size (default: 1024m)
  -noevents             disable event-driven input support
  -notimer              disable interval timer for low-res clock
  -pathenc <enc>        set encoding for pathnames (default: UTF-8)
  -plugins <path>       specify alternative plugin location (see manpage)
  -textenc <enc>        set encoding for external text (default: UTF-8)
  -version              print version information, then exit
  -vm-<sys>-<dev>       use the <dev> driver for <sys> (see below)
Deprecated:
  -display <dpy>        quivalent to '-vm-display-X11 -display <dpy>'
  -headless             quivalent to '-vm-display-X11 -headless'
  -nodisplay            quivalent to '-vm-display-null'
  -nosound              quivalent to '-vm-sound-null'
  -quartz               quivalent to '-vm-display-Quartz'

Notes:
  <imageName> defaults to `squeak.image'.
  -vtlock disables keyboard vt switching even when -vtswitch is enabled
  If `-memory' is not specified then the heap will grow dynamically.
  <argument>s are ignored, but are processed by the Squeak image.
  The first <argument> normally names a Squeak `script' to execute.
  Precede <arguments> by `--' to use default image.

Available drivers:
  vm-sound-null
  vm-sound-custom
  vm-display-custom
  vm-display-null
  vm-display-fbdev

--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

Henrik Sperre Johansen
On Sep 21, 2010, at 8:16 53AM, Lukas Renggli wrote:

>> How does Pharo execute classes from the command line?
>
> You can pass the filename of a .cs/.st file to the VM that gets
> filed-in on startup.
>
>> Is there a way to specify the class and the method to be called?
>
> Not directly.
>
>> Are command line arguments available?
>
> $ squeak --help
> Usage: squeak [<option>...] [<imageName> [<argument>...]]
>       squeak [<option>...] -- [<argument>...]
>

BTW, dunno if it's a crossplatform Cog issue ( haven't checked others) but in John's new OSX Cog-based VMs (last tested 5.8b9), it doesn't look like the arguments are present in systemAttributes at position 2 onwards.
Thus, ProjectLauncher will fail to execute scripts at all.


In -help:
>  -encoding <enc>       set the internal character encoding (default: MacRoman)

Sounds strangel, should probably be updated to Latin1/ removed (depending on how it's actually used)?


Also, nonrelated to the VM, the comment in SmalltalkImage>>#documentPath  seems misleading (not to mention the method name itself), there seems to be no conversion by the vm to absolute path going on in neither OSX nor Windows, the string is passed through raw.
This is reinforced by the --help mentioning:
> The first <argument> _normally_ names a Squeak `script' to execute.


Cheers,
Henry


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

Nicolas Cellier
2010/9/21 Henrik Johansen <[hidden email]>:

> On Sep 21, 2010, at 8:16 53AM, Lukas Renggli wrote:
>
>>> How does Pharo execute classes from the command line?
>>
>> You can pass the filename of a .cs/.st file to the VM that gets
>> filed-in on startup.
>>
>>> Is there a way to specify the class and the method to be called?
>>
>> Not directly.
>>
>>> Are command line arguments available?
>>
>> $ squeak --help
>> Usage: squeak [<option>...] [<imageName> [<argument>...]]
>>       squeak [<option>...] -- [<argument>...]
>>
>
> BTW, dunno if it's a crossplatform Cog issue ( haven't checked others) but in John's new OSX Cog-based VMs (last tested 5.8b9), it doesn't look like the arguments are present in systemAttributes at position 2 onwards.
> Thus, ProjectLauncher will fail to execute scripts at all.
>
>
> In -help:
>>  -encoding <enc>       set the internal character encoding (default: MacRoman)
>
> Sounds strangel, should probably be updated to Latin1/ removed (depending on how it's actually used)?
>

I bet less than 1 out of 1000 machines running squeak shall use this
MacRoman thing nowadays.

Nicolas

>
> Also, nonrelated to the VM, the comment in SmalltalkImage>>#documentPath  seems misleading (not to mention the method name itself), there seems to be no conversion by the vm to absolute path going on in neither OSX nor Windows, the string is passed through raw.
> This is reinforced by the --help mentioning:
>> The first <argument> _normally_ names a Squeak `script' to execute.
>
>
> Cheers,
> Henry
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

Henrik Sperre Johansen

On Sep 21, 2010, at 4:21 22PM, Nicolas Cellier wrote:

2010/9/21 Henrik Johansen <[hidden email]>:
On Sep 21, 2010, at 8:16 53AM, Lukas Renggli wrote:

How does Pharo execute classes from the command line?

You can pass the filename of a .cs/.st file to the VM that gets
filed-in on startup.

Is there a way to specify the class and the method to be called?

Not directly.

Are command line arguments available?

$ squeak --help
Usage: squeak [<option>...] [<imageName> [<argument>...]]
      squeak [<option>...] -- [<argument>...]


BTW, dunno if it's a crossplatform Cog issue ( haven't checked others) but in John's new OSX Cog-based VMs (last tested 5.8b9), it doesn't look like the arguments are present in systemAttributes at position 2 onwards.
Thus, ProjectLauncher will fail to execute scripts at all.


In -help:
 -encoding <enc>       set the internal character encoding (default: MacRoman)

Sounds strangel, should probably be updated to Latin1/ removed (depending on how it's actually used)?


I bet less than 1 out of 1000 machines running squeak shall use this
MacRoman thing nowadays.

Nicolas

Just ran -help on 5.2.5 and 5.8b9, the -encoding option is not mentioned in any of those.

The only current use case I could think of would be Cuis, who might want to set it to Latin15 in order to interpret € correctly.
Sure, the StrikeFonts (taken from Cuis) included in Pharo/Squeak actually cover Latin15 as well, but everywhere else, encoding of ByteStrings is assumed to be Latin1... 
So better with some visual discrepancies, namely displaying ¤ as €, € as ?, etc. than reading/writing the wrong characters to/from external sources

Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

johnmci
In reply to this post by jamesl


Begin forwarded message:

> From: John M McIntosh <[hidden email]>
> Date: September 21, 2010 3:55:54 PM PDT
> To: Henrik Johansen <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Pharo-project] Launching class form command line ...
> Reply-To: [hidden email]
>
>
>
> On 2010-09-21, at 7:01 AM, Henrik Johansen wrote:
>>>
>>
>> BTW, dunno if it's a crossplatform Cog issue ( haven't checked others) but in John's new OSX Cog-based VMs (last tested 5.8b9), it doesn't look like the arguments are present in systemAttributes at position 2 onwards.
>> Thus, ProjectLauncher will fail to execute scripts at all.
>
> This should work, can you supply an example of use.
>
>
>>
>>
>> In -help:
>>> -encoding <enc>       set the internal character encoding (default: MacRoman)
>>
>> Sounds strangel, should probably be updated to Latin1/ removed (depending on how it's actually used)?
>
> No the only supported type is UTF8. I've removed the bogus help text line.
>
>
>>
>>
>> Also, nonrelated to the VM, the comment in SmalltalkImage>>#documentPath  seems misleading (not to mention the method name itself), there seems to be no conversion by the vm to absolute path going on in neither OSX nor Windows, the string is passed through raw.
>> This is reinforced by the --help mentioning:
>>> The first <argument> _normally_ names a Squeak `script' to execute.
>
>
> Any comment in the image might be 15 years out of date.
>
>
>
>>
>>
>> Cheers,
>> Henry
>>
>
> --
> ===========================================================================
> John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
>
>
--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================





_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

Henrik Sperre Johansen

On Sep 22, 2010, at 3:12 10AM, John M McIntosh wrote:

>
>
> Begin forwarded message:
>
>> From: John M McIntosh <[hidden email]>
>> Date: September 21, 2010 3:55:54 PM PDT
>> To: Henrik Johansen <[hidden email]>
>> Cc: [hidden email]
>> Subject: Re: [Pharo-project] Launching class form command line ...
>> Reply-To: [hidden email]
>>
>>
>>
>> On 2010-09-21, at 7:01 AM, Henrik Johansen wrote:
>>>>
>>>
>>> BTW, dunno if it's a crossplatform Cog issue ( haven't checked others) but in John's new OSX Cog-based VMs (last tested 5.8b9), it doesn't look like the arguments are present in systemAttributes at position 2 onwards.
>>> Thus, ProjectLauncher will fail to execute scripts at all.
>>
>> This should work, can you supply an example of use.

Here are the command lines I used:

/Applications/Squeak\ 4.2.5beta1U.app/Contents/MacOS/Squeak\ VM\ Opt /Users/henrikjohansen/Dropbox/Pharo/PharoCore-1.2-12137.image spaceTally.st

In image:
Smalltalk documentPath  'spaceTally.st'

/Applications/Squeak\ 64-32\ 5.7b1.app/Contents/MacOS/Squeak /Users/henrikjohansen/Dropbox/Pharo/PharoCore-1.2-12137.image spaceTally.st

In image:
Smalltalk documentPath nil
('spaceTally.st' not in any system attribute < 4000 either)

/Applications/Squeak\ 5.8b9.app/Contents/MacOS/Squeak /Users/henrikjohansen/Dropbox/Pharo/PharoCore-1.2-12137.image spaceTally.st

Same in-image behavior as 5.7b1.

So doesn't seem specifically Cog-related, as it affects 5.7 as well

Cheers,
Henry
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

David T. Lewis
In reply to this post by Henrik Sperre Johansen
On Tue, Sep 21, 2010 at 04:44:19PM +0200, Henrik Johansen wrote:

>
> On Sep 21, 2010, at 4:21 22PM, Nicolas Cellier wrote:
>
> > 2010/9/21 Henrik Johansen <[hidden email]>:
> >> On Sep 21, 2010, at 8:16 53AM, Lukas Renggli wrote:
> >>
> >>>> How does Pharo execute classes from the command line?
> >>>
> >>> You can pass the filename of a .cs/.st file to the VM that gets
> >>> filed-in on startup.
> >>>
> >>>> Is there a way to specify the class and the method to be called?
> >>>
> >>> Not directly.
> >>>
> >>>> Are command line arguments available?
> >>>
> >>> $ squeak --help
> >>> Usage: squeak [<option>...] [<imageName> [<argument>...]]
> >>>       squeak [<option>...] -- [<argument>...]
> >>>
> >>
> >> BTW, dunno if it's a crossplatform Cog issue ( haven't checked others) but in John's new OSX Cog-based VMs (last tested 5.8b9), it doesn't look like the arguments are present in systemAttributes at position 2 onwards.
> >> Thus, ProjectLauncher will fail to execute scripts at all.
> >>
> >>
> >> In -help:
> >>>  -encoding <enc>       set the internal character encoding (default: MacRoman)
> >>
> >> Sounds strangel, should probably be updated to Latin1/ removed (depending on how it's actually used)?
> >>
> >
> > I bet less than 1 out of 1000 machines running squeak shall use this
> > MacRoman thing nowadays.
> >
> > Nicolas
>
> Just ran -help on 5.2.5 and 5.8b9, the -encoding option is not mentioned in any of those.
>
> The only current use case I could think of would be Cuis, who might want to set it to Latin15 in order to interpret ? correctly.
> Sure, the StrikeFonts (taken from Cuis) included in Pharo/Squeak actually cover Latin15 as well, but everywhere else, encoding of ByteStrings is assumed to be Latin1...
> So better with some visual discrepancies, namely displaying ? as ?, ? as ?, etc. than reading/writing the wrong characters to/from external sources

Regarding command line arguments available to the image, see #getSystemAttribute:

Squeak has #argumentAt: for getting command line options passed to the image.
This is no longer present in Pharo, but the implementation is just this:

    argumentAt: i
        "Answer the i-th argument of the command line, or nil if not so many argument."
        ^self getSystemAttribute: 2 + i

Dave


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Launching class form command line ...

Stéphane Ducasse
In reply to this post by Henrik Sperre Johansen
Thanks David
but It is defined in SmalltalkImage same implementation

>>>>>>
>    argumentAt: i
>        "Answer the i-th argument of the command line, or nil if not so many argument."
>        ^self getSystemAttribute: 2 + i
>
> Dave
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project