I meant, by "written long form" that it wasn't valid syntax… but it was
supposed to be easier to understand:

set(:branch, lambda { .... })

is the required way...

On 15 November 2011 18:30, Craig White <[email protected]> wrote:

>
> On Nov 15, 2011, at 10:07 AM, Lee Hambley wrote:
>
> > You can use Capistrano::CLI::ask in a early task to ask for such
> credentials, here's something from my app which I use to ask the user for
> the branch name, with a sensible default, this is shared between :
> >
> > set :branch, lambda do
> >   a = Capistrano::CLI.password_prompt("SHA1/Branch/Tag to deploy [#{`git
> describe --abbr=0`.strip}]: ");
> >   if a.empty?
> >     `git describe --abbr=0`.strip
> >   else
> >     a
> >   end
> > end
> >
> > This is written out the longhand way, but you probably could compress it
> into one line, that's another alternative for you, nice side-effect of this
> being a lambda, is that the prompt isn't displayed until you try to use the
> variable, so tasks which don't need to answer all prompts won't have to.
> >
> > Another side effect of this though, is that you'll want to make sure
> you're not using the variable for the first time inside one of your own
> run() commands, otherwise you risk being prompted once for each server. For
> things like passwords/etc used internally, this is no problem.
> ----
> there's obviously something I am missing...
>
> $ cap test2 deploy:code
> ./config/deploy.rb:297:in `lambda': tried to create Proc object without a
> block (ArgumentError)
>        from ./config/deploy.rb:297:in `load'
>
> and line 297 is the first line of this 'set' command...
>
> set :user, lambda do
>  my_user = Capistrano::CLI.ui.ask("Your SSH User name [#{`user`.strip}]:
> ");
>  if my_user.empty?
>    `user`.strip
>  else
>    my_user
>  end
> end
>
> (though I suspect that `user` is a problem, I didn't get that far)
>
> Thanks
>
> Craig
>
> --
> * You received this message because you are subscribed to the Google
> Groups "Capistrano" group.
> * To post to this group, send email to [email protected]
> * To unsubscribe from this group, send email to
> [email protected] For more options, visit this
> group at http://groups.google.com/group/capistrano?hl=en
>

-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to 
[email protected] For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to