Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions repository/Scripting/HeadlessSave.class.st
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Class {
#name : #HeadlessSave,
#superclass : #Object,
#category : 'Scripting'
#category : #'Scripting-Core'
}

{ #category : #'script entry' }
HeadlessSave class >> run: arguments [
| proc |
| proc |
proc := [
| basicName newName |
| basicName newName imageName |
ScriptConsole println: 'Do wait, let system run non-busy, and then save and quit'.
(Delay forSeconds: 10) wait.
ScriptConsole println: 'Do headless save now.'.
basicName := SmalltalkImage current imageName withoutLast: '.image' size.
imageName := SmalltalkImage current shortImageName.
basicName := imageName asFileReference withoutExtension basename.
newName := basicName, '-headless.image'.
SmalltalkImage current saveAs: newName.
SmalltalkImage current snapshot: false andQuit: true.
Expand Down
7 changes: 4 additions & 3 deletions repository/Scripting/Run.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Run is a class that will take the command line arguments and will try to evaluat
Class {
#name : #Run,
#superclass : #Object,
#category : 'Scripting'
#category : #'Scripting-Core'
}

{ #category : #'script entry' }
Expand All @@ -17,6 +17,7 @@ Run class >> run: args [
ScriptConsole println: str.
ScriptConsole println: args asString.
ScriptConsole println: 'Going to evaluate the string'.
[ self compiler evaluate: str. ]
ifError: [:err :rcvr | ScriptConsole println: 'Error: ', err].
[ self compiler evaluate: str ]
on: Error
do: [ : err | ScriptConsole println: 'Error: ', err ].
]
23 changes: 11 additions & 12 deletions repository/Scripting/ScriptConsole.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
'Position',
'PrintTarget'
],
#category : 'Scripting'
#category : #'Scripting-Core'
}

{ #category : #streaming }
Expand Down Expand Up @@ -60,7 +60,7 @@ ScriptConsole class >> flush [
PrintTarget ifNotNil: [PrintTarget flush].
]

{ #category : #initialization }
{ #category : #'class initialization' }
ScriptConsole class >> initialize [
"ScriptConsole initialize"
OutputToTranscript := false.
Expand Down Expand Up @@ -106,25 +106,24 @@ ScriptConsole class >> print: somethingAsString [
{ #category : #printing }
ScriptConsole class >> print: somethingAsString withLineEnding: lineEnd [
"Will output the somethingAsString to stdout using one of the available mechansims and to the transcript if requested"

| output |
output := somethingAsString asString.
Position := Position + output size.
output size > 0 ifTrue: [
LastPrintedChar := output last].

output size > 0 ifTrue: [ LastPrintedChar := output last ].

PrintTarget ifNotNil: [
IsRVM
ifTrue: [ PrintTarget print: output. ]
ifTrue: [ PrintTarget print: output ]
ifFalse: [
PrintTarget
nextPutAll: output;
nextPutAll: lineEnd ].
].
nextPutAll: lineEnd ] ].

(OutputToTranscript or: [PrintTarget isNil])
ifTrue: [
Transcript show: output, lineEnd.
].
(OutputToTranscript or: [ PrintTarget isNil ]) ifTrue: [
Transcript
show: output;
show: lineEnd ]
]

{ #category : #printing }
Expand Down
42 changes: 20 additions & 22 deletions repository/Scripting/ScriptStarter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
'QuitVM',
'SafeBeforeQuit'
],
#category : 'Scripting'
#category : #'Scripting-Core'
}

{ #category : #helper }
Expand All @@ -30,16 +30,18 @@ ScriptStarter class >> executeRunFor: scriptClassName with: arguments [

{ #category : #helper }
ScriptStarter class >> getSystemAttributes [

| arguments arg i |
arguments := OrderedCollection new.
i := 2.
[[arg := Smalltalk vm getSystemAttribute: i] value == nil]
whileFalse: [arguments addLast: arg.
i := i + 1].
[ [ arg := Smalltalk vm getSystemAttribute: i ] value isNil ]
whileFalse: [
arguments addLast: arg.
i := i + 1 ].
^ arguments
]

{ #category : #initialization }
{ #category : #'class initialization' }
ScriptStarter class >> initialize [
"Automatically install ScriptStarter when the code is filed in."
self install.
Expand Down Expand Up @@ -89,36 +91,32 @@ ScriptStarter class >> saveImageBeforeQuit: aBool [
SafeBeforeQuit := aBool
]

{ #category : #'system startup entry' }
{ #category : #'system startup' }
ScriptStarter class >> startUp [
"startUp is invoked during startup.
ScriptStarter has to be registered in the SystemDirectory's StartUpList
See ScriptStarter>>install"


| arguments scriptClassName |
"Ok, only, and really only during startup"
IsResuming ifFalse: [ Transcript show: 'ScriptStarter did not execute a given script, since it assumes to be executed after a snapshot and not during startup.'.
^ self. ].

"First make sure that stdout output can be used if available."
IsResuming ifFalse: [
Transcript show:
'ScriptStarter did not execute a given script, since it assumes to be executed after a snapshot and not during startup.'.
^ self ].
ScriptConsole detectAvailableMechanismForStdout.

arguments := self getSystemAttributes.
arguments size > 0
ifTrue: [scriptClassName := arguments at: 1.
self executeRunFor: scriptClassName with: arguments.]
arguments size > 0 ifFalse: [ ^ self ].
scriptClassName := arguments at: 1.
self executeRunFor: scriptClassName with: arguments
]

{ #category : #'system startup entry' }
{ #category : #'system startup' }
ScriptStarter class >> startUp: resuming [
IsResuming := resuming.
^ super startUp: resuming.
]

{ #category : #transporter }
ScriptStarter class >> transportersForFileOutMenu [
^ { (Smalltalk at: #Transporter ifAbsent: [^#()])
forPackage: (PackageInfo named: 'Scripting') }

^ { ((Smalltalk at: #Transporter ifAbsent: [ ^ #( ) ]) forPackage:
(RPackageOrganizer default packageNamed: 'Scripting')) }
]

{ #category : #'system startup entry' }
Expand Down
10 changes: 7 additions & 3 deletions repository/Scripting/SubunitRunner.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Class {
#classVars : [
'DefaultOutputTarget'
],
#category : 'Scripting'
#category : #'Scripting-Core'
}

{ #category : #defaults }
Expand Down Expand Up @@ -50,7 +50,8 @@ SubunitRunner class >> run: arguments [

{ #category : #running }
SubunitRunner class >> runAllTests [
self runClasses: Smalltalk allClasses named: 'All'.

self runClasses: Smalltalk globals allClasses named: 'All'
]

{ #category : #running }
Expand Down Expand Up @@ -79,7 +80,10 @@ SubunitRunner class >> runClasses: aCollectionOfClasses named: aString [

{ #category : #running }
SubunitRunner class >> runPackage: aString [
^ self runClasses: (PackageInfo named: aString) classes named: aString

^ self
runClasses: (RPackageOrganizer default packageNamed: aString) classes
named: aString
]

{ #category : #running }
Expand Down
13 changes: 7 additions & 6 deletions repository/Scripting/UpdateImage.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #UpdateImage,
#superclass : #Object,
#category : 'Scripting'
#category : #'Scripting-Core'
}

{ #category : #'script entry' }
Expand All @@ -15,12 +15,13 @@ UpdateImage class >> run: args [

"Use a delayed process to do the actual work"
proc := [ (Delay forSeconds: 5) wait.
"Create an up-to-date image"
(FileStream readOnlyFileNamed: 'FileInAllRenaissanceCode.st') fileIn.
Transcript show: 'Snapshot and Quit now...'.
Smalltalk snapshot: true andQuit: true. ] newProcess.
"Create an up-to-date image"
'FileInAllRenaissanceCode.st' asFileReference fileIn.
Transcript show: 'Snapshot and Quit now...'.
Smalltalk snapshot: true andQuit: true
] newProcess.

proc name: 'Update Image'.
proc resume.

]