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

Add IO#noecho and IO#noecho! #3035

Merged
merged 2 commits into from
Jul 23, 2016
Merged

Add IO#noecho and IO#noecho! #3035

merged 2 commits into from
Jul 23, 2016

Conversation

jhass
Copy link
Member

@jhass jhass commented Jul 23, 2016

These disable printing what's entered into the terminal.

require "io/console"
print "Enter password: "
password = STDIN.noecho &.gets.try &.chomp
puts

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@asterite
Copy link
Member

Nice! I thought this was going to be much harder to implement.

Do you want to add some docs to the method? I noticed Ruby has the method so copying the docs should be fine.

@jhass
Copy link
Member Author

jhass commented Jul 23, 2016

Alright, done.

@asterite
Copy link
Member

Hmmm... why there's no travis check for this?

@jhass
Copy link
Member Author

jhass commented Jul 23, 2016

There is, see the checkmark next to the first commit, the second commit is just docs, so I [ci skip]ed it.

@asterite
Copy link
Member

Ah, I didn't know that.

Thanks for the extra docs! :-)

@asterite asterite merged commit 428acab into crystal-lang:master Jul 23, 2016
@asterite asterite added this to the 0.19.0 milestone Jul 23, 2016
@jhass jhass deleted the noecho branch July 25, 2016 07:57
@elorest
Copy link
Contributor

elorest commented Jun 8, 2017

Would it be possible to add this as well.
http://ruby-doc.org/stdlib-2.3.0/libdoc/io/console/rdoc/IO.html#method-i-getpass

getpass(prompt=nil)
  print "#{prompt}:" if prompt
  password = STDIN.noecho &.gets.try &.chomp
  password
end

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

Successfully merging this pull request may close these issues.

None yet

3 participants