[ENH] Automate User Inputs
stéphane ducasse
ducasse at iam.unibe.ch
Tue Oct 5 17:37:51 UTC 2004
Nice work. I would like to get some feedback because this is really
needed and we discussed long time ago about that.
marcus I would really like to see that in the unstable stream
Stef
On 5 oct. 04, at 01:57, John Pierce wrote:
> Change Set: automate.user.inputs-jrp
> Date: 4 October 2004
> Author: John Pierce
>
> When performing batch processing activities, like a configuration
> script that I've worked up to auto-build my Squeak images with my
> favorite programs, you will inevitably run into SqueakMap packages,
> Monticello packages, and other programs that require user input during
> their installation.
>
> This changeset will add an enhancement to PopUpMenu and
> FillInTheBlankMorph such that they can request answers to their
> questions by signaling a ProvideAnswerNotification. On BlockContext I
> provide helpers to catch this notification and look for an appropriate
> answer in one of the provided parameters. The basic syntax looks
> like:
>
> [self confirm: 'Install spyware?'] valueSupplyingAnswer: #('Install
> spyware?' false)
>
> There a few variants on this theme making it easy to provide a literal
> list of answers for the block so that you can handle a bunch of
> questions in a block with appropriate answers.
>
> Additionally, I make it possible to suppress Object>>inform: modal
> messages as these get in the way of automated batch scripts. After
> applying this changeset you should be able to tryout the following
> code snippets to see the variants I made available.
>
> Note: I could be convinced that the 'helpers' should not be on
> BlockContext, but I started there as it was the simplest syntax and,
> thus, my first choice. For advanced usage, check out my configuration
> script that auto-builds a fresh 3.7 image at:
> www.saltypickle.com/Home/xp and most definitely needs this sort of
> automation.
>
> Examples:
>
> So you don't need any introduction here -- this one works like usual.
> [self inform: 'hello'. #done] value.
>
> Now lets suppress all inform: messages.
> [self inform: 'hello'; inform: 'there'. #done]
> valueSuppressingAllMessages.
>
> Here we can just suppress a single inform: message.
> [self inform: 'hi'; inform: 'there'. #done] valueSuppressingMessages:
> #('there')
>
> Here you see how you can suppress a list of messages.
> [self inform: 'hi'; inform: 'there'; inform: 'bill'. #done]
> valueSuppressingMessages: #('hi' 'there')
>
> Enough about inform:, let's look at confirm:. As you see this one
> works as expected.
> [self confirm: 'You like Squeak?'] value
>
> Let's supply answers to one of the questions -- check out the return
> value.
> [{self confirm: 'You like Smalltalk?'. self confirm: 'You like
> Squeak?'}]
> valueSupplyingAnswer: #('You like Smalltalk?' true)
>
> Here we supply answers using only substrings of the questions (for
> simplicity).
> [{self confirm: 'You like Squeak?'. self confirm: 'You like MVC?'}]
> valueSupplyingAnswers: #( ('Squeak' true) ('MVC' false) )
>
> This time let's answer all questions exactly the same way.
> [{self confirm: 'You like Squeak?'. self confirm: 'You like Morphic?'}]
> valueSupplyingAnswer: true
>
> And, of course, we can answer FillInTheBlank questions in the same
> manner.
> [FillInTheBlank request: 'What day is it?']
> valueSupplyingAnswer: 'the first day of the rest of your life'
>
> We can also return whatever the initialAnswer of the FillInTheBlank
> was by using the #default answer.
> [FillInTheBlank request: 'What day is it?' initialAnswer: DateAndTime
> now dayOfWeekName]
> valueSupplyingAnswer: #default
>
> Finally, I made it so you can also do regex matches on any of the
> question text (or inform text).
> [FillInTheBlank request: 'What day is it?']
> valueSupplyingAnswers: { {'What day.*\?'. DateAndTime now
> dayOfWeekName} }
>
>
> Regards,
>
> John
>
> --
> Three failures denote uncommon strength. A weakling has not enough
> grit to fail thrice. -- Minna Thomas Antrim
> <automate.user.inputs-jrp.3.cs.gz>
More information about the Squeak-dev
mailing list
|