[Cuis-dev] [IMPROV] Configurable command line exception handling

Gerald Klix cuis.01 at klix.ch
Sun Jan 15 04:36:47 PST 2023


Hi Juan

Thanks a lot!
That one is better than my solution, less instance variables,
no #ifNil: stuff.

If we update the Cuis book, we should not forget,
which of those #start*Argument and #lastCommandLineArguments-methods
answer a copy and which don't.


Best Regards,

Gerald


On 1/15/23 1:03 AM, Juan Vuletich wrote:
> Hi Gerald,
>
> Just pushed a slight variation. Your example works as intended.
>
> Thanks,
>
> On 1/14/2023 12:39 PM, Gerald Klix via Cuis-dev wrote:
>> Hi Juan,
>>
>> I had a closer look at your implementation.
>> It is less code and looks simpler, but it uses offsets and indexes,
>> therefore I find it harder to understand.
>>
>> It has the following drawbacks/missing features:
>>
>>    1. It is not possible to pass options to scripts, they are are all
>>       consumed
>>       by the parsing code and then ether honored or ignored.
>>    2. In order to implement #lastCommandLineArguments  properly, you
>>       have to look *ahead* for a --.
>>       Of course before parsing, the arguments after -- can  be stored
>>       in an instance variable
>>
>> I am against implementing feature 1, because
>> it implies once we add new options understood by Cuis' image,
>> the options passed to the script would change in a rather surprising 
>> way.
>>
>> The attached changes set implements feature 2.
>> It only adds an instance variable and about 7 lines of code.
>> With it you can do something like:
>>
>> --- snip ---
>> squeak -vm-display-null -headless Cuis6.0-5632cli2.image -d 
>> "Smalltalk scriptingArguments do: [ :arg | StdIOWriteStream stdout 
>> nextPutAll: arg; space]. StdIOWriteStream stdout newLine" a b c dee 
>> -d "Smalltalk scriptingArguments do: [ :arg | StdIOWriteStream stdout 
>> nextPutAll: arg; space]. StdIOWriteStream stdout newLine" z y x why 
>> -q -- 1 2 3 -o
>> --- snap ---
>>
>> and get the following output:
>>
>> --- snip ---
>> a b c dee 1 2 3 -o
>> z y x why 1 2 3 -o
>> --- snap ---
>>
>> I suppose that should support all sensible uses cases.
>> I also presume, that all requirements  of Dr. Geo are fulfilled.
>>
>>
>> HTH and Best Regards,
>>
>> Gerald
>>
>>
>
>



More information about the Cuis-dev mailing list