CLI.ui.ask does not prompt

344 views
Skip to first unread message

Gerhardus Geldenhuis

unread,
Jan 19, 2009, 7:49:51 AM1/19/09
to Capistrano
Hi
I can't get the following code snippet to work.

task :promptme, :roles => :gg do
set(:user) { Capistrano::CLI.ui.ask("User name: ") }
end

I expected it to prompt me on the command line when running cap
promptme but it does not prompt me at all.

cap promptme
* executing `promptme'

When running the command it just exits immediately.

Any ideas?

Best Regards




Jamis Buck

unread,
Jan 19, 2009, 9:56:18 AM1/19/09
to capis...@googlegroups.com
When passing a block to set(), the block is not evaluated immediately,
but is instead evaluated the next time the variable is referenced. It's
called "lazy evaluation", and lets you defer the evaluation until the
variable is actually needed.

If you want it evaluated immediately, don't use a block:

set(:user, Capistrano::CLI.ui.ask("User name: "))

- Jamis

Xazoola

unread,
Jan 19, 2009, 12:41:44 PM1/19/09
to Capistrano
thanks I was having the same problem :)
Reply all
Reply to author
Forward
0 new messages