[Cuis-dev] File in changes file on startup from command line

Mariano Montone marianomontone at gmail.com
Tue Jun 29 05:43:46 PDT 2021


Hello,

I've added an "-l" (load) command line parameter for filing in changeset
files.

"-r", and "-s" do not work for filing in that kind of files.

I'm using it like this:

../sqcogspur64linuxht/squeak Cuis-Smalltalk-Dev/MetaBrowser.image -l
MyChanges.cs.st -s ~/.cuisrc

Is this new command line option necessary for my purposes? (perhaps I'm
missing something, and the same thing can be achieved in other way.)

I attach my implementation of the "load" command line option.

I've just added this:

[ $l ] -> ["file in the file"
	{ 'File in: '. data} print.
	[(CodeFile newFromFile: data asFileEntry) fileIn] on: UnhandledError
do: [:ex | ex return]].

Cheers,

Mariano
-------------- next part --------------
'From Cuis 5.0 [latest update: #4619] on 28 June 2021 at 11:33:40 pm'!

!SystemDictionary methodsFor: 'startup' stamp: 'MM 6/28/2021 23:26:17'!
processCommandLineArgument: rawArgStream storeStartUpScriptArgsOn: startUpScriptArgs
	"
	Smalltalk processCommandLineArguments
	
	A possible example (duplicated single quotes: '' should be double quotes, but not allowed in a Smalltalk comment):
	Squeak.exe Cuis4.2-2211x.image -r RequiredFeature1 -rRequiredFeature2 -d ''Transcript show: 'popo1'; newLine'' -d''Transcript show: 'popo2'; newLine'' -s smalltalkScript.st paramAlScript1 paramAlSCript2 ''parametro al script ->>>--// 3''
	"
	| p data entry |
	p _ rawArgStream next.

	(p first = $- and: [ p size > 1 ]) ifTrue: [
		"If the command is not included in p, it is next argument"
		p size = 2
			ifTrue: [
				"as in 		-r RequiredFeature1"
				data _ rawArgStream next ]
			ifFalse: [
				"as in 		-rRequiredFeature2"
				data _ p copyFrom: 3 to: p size ].
		p second caseOf: {
			[ $r ] -> [		"as in 		-rRequiredFeature2"
				{ 'Feature require: '. data } print.
				[ Feature require: data ] on: UnhandledError do: [:ex | ex return] ].
			[ $d ] -> [		"as in 		-d ''Transcript show: 'popo1'; newLine'' -d''Transcript show: 'popo2'; newLine''        (duplicated singleQuotes should read doubleQuote)"
				{ 'Compiler evaluate: '. data } print.
				[ Compiler evaluate: data ] on: UnhandledError do: [:ex | ex return] ].
			[$l ] -> ["file in the file"
				{ 'File in: '. data} print.
				[(CodeFile newFromFile: data asFileEntry) fileIn] on: UnhandledError do: [:ex | ex return]].
			[ $s ] -> [		"as in 		-s smalltalkScript.st paramAlScript1 paramAlSCript2 ''parametro al script ->>>--// 3'' 			(duplicated singleQuotes should read doubleQuote)"
				[ rawArgStream atEnd ] whileFalse: [
					startUpScriptArgs nextPut: rawArgStream next ].
				"Can use 'Smalltalk startUpScriptArguments' inside the startUp script
				{ 'Compiler evaluate contents of file named: '. data. ' arguments: '. Smalltalk startUpScriptArguments } print."
				entry _ data asFileEntry.
				entry exists ifTrue: [
					entry readStreamDo: [ :stream |
						[ Compiler evaluate: stream contentsOfEntireFile ] on: UnhandledError do: [:ex | ex return]]].
				"Maybe we decide to clear them after startup script execution
				startUpScriptArguments _ nil" ]
		}
		otherwise: []
	]! !


More information about the Cuis-dev mailing list