Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to ask for a password? #108

Closed
ritxi opened this issue Jan 13, 2011 · 6 comments
Closed

Is it possible to ask for a password? #108

ritxi opened this issue Jan 13, 2011 · 6 comments

Comments

@ritxi
Copy link

ritxi commented Jan 13, 2011

I'm trying to use thor in an script that asks a password, but I would prefere if it's not shown.

ask("fill your password:", :password => true) would be nice

or ask_password("fill your password")

Thanks in advance!

@josevalim
Copy link
Contributor

Nops, we don't have this feature. last time I checked it was a bit complicated to implement in an OS agnostic way.

@indirect
Copy link
Member

If you'd like an example, check out the engineyard gem, which implements this using the highline gem.

@ritxi
Copy link
Author

ritxi commented Jan 14, 2011

Thanks I know about highline it was just if it was possible with thor directly.

https://gist.github.com/779615

@jacobbednarz
Copy link

Possibly a cleaner solution.

cli = HighLine.new
password = cli.ask("Enter your password: ") { |q| q.echo = false }

@diasjorge
Copy link

you can do something like:

require 'io/console'
password = $stdin.noecho do
  ask "password"
end

@diasjorge
Copy link

Actually for future references if you come from google. With the latest version you can do

ask("What is your password?", :echo => false)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants