[Pkg] The Trunk: CommandLine-fbs.1.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Oct 31 22:32:15 UTC 2013

Frank Shearar uploaded a new version of CommandLine to project The Trunk:

==================== Summary ====================

Name: CommandLine-fbs.1
Author: fbs
Time: 31 October 2013, 10:32:52.821 pm
UUID: dc871e85-bd16-d742-acbf-4d2b838113d1

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') -----
	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') -----

----- 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: [
			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') -----
	<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') -----
	ToolSet unregister: self.!

More information about the Packages mailing list