gem install highline
require 'highline/import'
ask('password: ') {|q| q.echo = '*' }
On Mar 13, 9:00 am, ara.t.how... / noaa.gov wrote:
> On Tue, 13 Mar 2007, Trans wrote:
> > This has been asked about before, and I've been wondering about it
> > myself. So I worked on it and came up with this. I know it's rather a
> > poor man's way of handling it but at least it's light and portable
> > (well, at least I think it is).
>
> > def password( msg=nil )
> > msg ||= "Enter Password"
> > inp = ''
>
> > i = Thread.new{ inp = $stdin.gets }
> > c = Thread.new do
> > loop do
> > sleep 0.01
> > $stdout << "\r#{msg}: "
> > $stdout << "\r#{msg}: "
> > $stdout.flush
> > end
> > end
>
> > i.join
>
> > return inp
> > end
>
> gem install highline !!
>
> ;-)
>
> -a
> --
> be kind whenever possible... it is always possible.
> - the dalai lama