[Omake] Confirmation dialog
Aleksey Nogin
nogin at metaprl.org
Sun Feb 17 20:24:03 PST 2008
On 17.02.2008 07:40, Andrew Gacek wrote:
> I want to guard one of my omakefile targets with a confirmation
> dialog. For example, I want something like the following
>
> % omake guarded-target
> Warning. Running this command will do XYZ. Types YES to confirm.
>
> Is there a straightforward way to do this? I've tried using input-line
> as follows
>
> RESULT = $(input-line $(stdin))
>
> But this gives the error: "Non digestible value".
Andrew,
Your input-line approach is probably the right one, you just need to
make sure you reference $(stdin) outside of the rule body - e.g. in a
helper function or in a Shell alias.
For example, the following works for me:
------------------------------------------
.PHONY: test
confirm(msg) =
println($(msg))
print($"Type YES to confirm or press Enter to abort: ")
RESULT = $(input-line $(stdin))
if $(not $(mem $(RESULT), YES yes))
exit 1
test:
confirm($"This will eat your brain!")
println($"Consider your brain eaten!")
.DEFAULT: test
------------------------------------------
P.S. The reason you need stdin outisde of rule body, is that OMake
considers a rule body as an extra dependency and on repeated executions,
it will consider a target stale if the rule body have changed since the
target was last built. Well, if the body refers to channel, such as
$(stdin), than it can not really tell whether it's the same stdin, or a
different one - which causes this "Non digestible value" error.
Aleksey
More information about the Omake
mailing list