[squeak-dev] The Trunk: CommandLine-fbs.1.mcz
Chris Muller
asqueaker at gmail.com
Sat Nov 2 20:37:03 UTC 2013
Why did you use "SmalltalkImage current" instead of "Smalltalk?"
How about using the new Error>>#printDetailsOn:?
Why does this need to be yet another new package instead of simply
part of Tools? It's two classes that should never be unloaded,
because command-line operations are something that should always be
part of the system.
On Thu, Oct 31, 2013 at 5:32 PM, <commits at source.squeak.org> wrote:
> Frank Shearar uploaded a new version of CommandLine to project The Trunk:
> http://source.squeak.org/trunk/CommandLine-fbs.1.mcz
>
> ==================== Summary ====================
>
> Name: CommandLine-fbs.1
> Author: fbs
> Time: 31 October 2013, 10:32:52.821 pm
> UUID: dc871e85-bd16-d742-acbf-4d2b838113d1
> Ancestors:
>
> CommandLineToolSet does little more than dump errors to stderr.
>
> DummyUIManager comes from Pharo via Pavel Krivanek's minimising script.
>
> ==================== Snapshot ====================
>
> SystemOrganization addCategory: #'CommandLine-Tools'!
> SystemOrganization addCategory: #'CommandLine-UIManager'!
>
> UIManager subclass: #DummyUIManager
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'CommandLine-UIManager'!
>
> !DummyUIManager commentStamp: 'fbs 10/31/2013 07:36' prior: 0!
> I'm an alternative UIManager used to run an the image without GUI. I redefine methods which require user input as these requests are irrelevant in a headless environment. !
>
> ----- Method: DummyUIManager>>checkForNewDisplaySize (in category 'display') -----
> checkForNewDisplaySize
> Display extent = DisplayScreen actualScreenSize ifTrue: [^ self].
> DisplayScreen startUp.
> !
>
> ----- Method: DummyUIManager>>chooseDirectory:from: (in category 'ui requests') -----
> chooseDirectory: label from: dir
> ^ nil!
>
> ----- Method: DummyUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----
> chooseFrom: aList lines: linesArray title: aString
> ^ aList first!
>
> ----- Method: DummyUIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
> chooseFrom: labelList values: valueList lines: linesArray title: aString
> ^ valueList first!
>
> ----- Method: DummyUIManager>>confirm: (in category 'ui requests') -----
> confirm: queryString
> (ProvideAnswerNotification signal: queryString)
> ifNotNil: [:answer|^answer].
>
> self error: 'No user response possible'!
>
> ----- Method: DummyUIManager>>confirm:orCancel: (in category 'ui requests') -----
> confirm: aString orCancel: cancelBlock
> (ProvideAnswerNotification signal: aString) ifNotNil: [:answer |
> ^answer == #cancel ifTrue: [cancelBlock value] ifFalse: [answer]].
>
> self error: 'No user response possible'!
>
> ----- Method: DummyUIManager>>displayProgress:at:from:to:during: (in category 'ui requests') -----
> displayProgress: titleString at: aPoint from: minVal to: maxVal during: workBlock
> ^ workBlock value: Association new!
>
> ----- Method: DummyUIManager>>edit:label:accept: (in category 'ui requests') -----
> edit: aText label: labelString accept: anAction
> ^ nil!
>
> ----- Method: DummyUIManager>>fontFromUser: (in category 'ui requests') -----
> fontFromUser: priorFont
> self error: 'No user response possible'!
>
> ----- Method: DummyUIManager>>inform: (in category 'ui requests') -----
> inform: aString
> "Nothing to be done here"!
>
> ----- Method: DummyUIManager>>informUserDuring: (in category 'ui requests') -----
> informUserDuring: aBlock
> aBlock value: nil!
>
> ----- Method: DummyUIManager>>newDisplayDepthNoRestore: (in category 'display') -----
> newDisplayDepthNoRestore: pixelSize
> "Change depths. Check if there is enough space!! , di"
> | area need |
> pixelSize = Display depth ifTrue: [^ self "no change"].
> pixelSize abs < Display depth ifFalse:
> ["Make sure there is enough space"
> area := Display boundingBox area. "pixels"
>
> need := (area * (pixelSize abs - Display depth) // 8) "new bytes needed"
> + Smalltalk lowSpaceThreshold.
> (Smalltalk garbageCollectMost <= need
> and: [Smalltalk garbageCollect <= need])
> ifTrue: [self error: 'Insufficient free space']].
> Display setExtent: Display extent depth: pixelSize.
>
> DisplayScreen startUp!
>
> ----- Method: DummyUIManager>>request:initialAnswer: (in category 'ui requests') -----
> request: queryString initialAnswer: defaultAnswer
> (ProvideAnswerNotification signal: queryString)
> ifNotNil: [:answer |
> ^ answer == #default ifTrue: [defaultAnswer] ifFalse: [answer]].
>
> self error: 'No user response possible'!
>
> ----- Method: DummyUIManager>>requestPassword: (in category 'ui requests') -----
> requestPassword: queryString
> ^ self request: queryString initialAnswer: ''!
>
> ----- Method: DummyUIManager>>restoreDisplay (in category 'display') -----
> restoreDisplay!
>
> ----- Method: DummyUIManager>>restoreDisplayAfter: (in category 'display') -----
> restoreDisplayAfter: aBlock
> aBlock value.
> Sensor waitButton.!
>
> StandardToolSet subclass: #CommandLineToolSet
> instanceVariableNames: ''
> classVariableNames: 'SaveSnapshotOnError'
> poolDictionaries: ''
> category: 'CommandLine-Tools'!
>
> ----- Method: CommandLineToolSet class>>debugError: (in category 'debugging') -----
> debugError: anError
> "Print out a sensible stack trace and bail"
> | problemPlace s |
> self saveSnapshotOnError
> ifTrue: [Smalltalk saveAs: 'Debug-' , (Smalltalk imageName subStrings: '/') last].
> problemPlace := anError signalerContext.
> s := FileStream stderr.
> (anError isKindOf: MessageNotUnderstood) ifTrue: [
> s
> nextPutAll: anError messageText; cr;
> nextPutAll: problemPlace sender methodNode printString; cr].
> (problemPlace stackOfSize: 20) do: [:ctx | s cr. ctx printOn: s].
> s flush.
>
> SmalltalkImage current snapshot: false andQuit: true!
>
> ----- Method: CommandLineToolSet class>>debugSyntaxError: (in category 'debugging') -----
> debugSyntaxError: anError
> | s |
> s := FileStream stderr.
> s nextPutAll: '----- Syntax error -----'; cr.
> s nextPutAll: anError errorCode; cr.
> s nextPutAll: '----- Syntax error -----'; cr.
>
> self debugError: anError!
>
> ----- Method: CommandLineToolSet class>>saveSnapshotOnError (in category 'preferences') -----
> saveSnapshotOnError
> <preference: 'Save snapshot of image on failure'
> category: 'debug'
> description: 'If true, saves a snapshot of the failing image to the current directory.'
> type: #Boolean>
> ^ SaveSnapshotOnError ifNil: [SaveSnapshotOnError := false].!
>
> ----- Method: CommandLineToolSet class>>saveSnapshotOnError: (in category 'preferences') -----
> saveSnapshotOnError: aBoolean
> SaveSnapshotOnError := aBoolean.!
>
> ----- Method: CommandLineToolSet class>>unload (in category 'class initialization') -----
> unload
> ToolSet unregister: self.!
>
>
More information about the Squeak-dev
mailing list
|