Updates bgentry/speakeasy.

pull/2258/head
James Phillips 2016-08-09 16:31:32 -07:00
parent 287a5ef75e
commit 12da41e873
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
4 changed files with 12 additions and 12 deletions

View File

@ -1,2 +0,0 @@
example/example
example/example.exe

View File

@ -16,14 +16,14 @@ func Ask(prompt string) (password string, err error) {
// Same as the Ask function, except it is possible to specify the file to write
// the prompt to.
func FAsk(file *os.File, prompt string) (password string, err error) {
func FAsk(wr io.Writer, prompt string) (password string, err error) {
if prompt != "" {
fmt.Fprint(file, prompt) // Display the prompt.
fmt.Fprint(wr, prompt) // Display the prompt.
}
password, err = getPassword()
// Carriage return after the user input.
fmt.Fprintln(file, "")
fmt.Fprintln(wr, "")
return
}

View File

@ -3,7 +3,6 @@
package speakeasy
import (
"os"
"syscall"
)
@ -12,18 +11,17 @@ import (
const ENABLE_ECHO_INPUT = 0x0004
func getPassword() (password string, err error) {
hStdin := syscall.Handle(os.Stdin.Fd())
var oldMode uint32
err = syscall.GetConsoleMode(hStdin, &oldMode)
err = syscall.GetConsoleMode(syscall.Stdin, &oldMode)
if err != nil {
return
}
var newMode uint32 = (oldMode &^ ENABLE_ECHO_INPUT)
err = setConsoleMode(hStdin, newMode)
defer setConsoleMode(hStdin, oldMode)
err = setConsoleMode(syscall.Stdin, newMode)
defer setConsoleMode(syscall.Stdin, oldMode)
if err != nil {
return
}

8
vendor/vendor.json vendored
View File

@ -39,12 +39,16 @@
"revisionTime": "2016-01-15T23:47:25Z"
},
{
"checksumSHA1": "dvd7Su+WNmHRP1+w1HezrPUCDsc=",
"path": "github.com/bgentry/speakeasy",
"revision": "36e9cfdd690967f4f690c6edcc9ffacd006014a0"
"revision": "e1439544d8ecd0f3e9373a636d447668096a8f81",
"revisionTime": "2016-05-20T23:26:10Z"
},
{
"checksumSHA1": "twtRfb6484vfr2qqjiFkLThTjcQ=",
"path": "github.com/bgentry/speakeasy/example",
"revision": "36e9cfdd690967f4f690c6edcc9ffacd006014a0"
"revision": "e1439544d8ecd0f3e9373a636d447668096a8f81",
"revisionTime": "2016-05-20T23:26:10Z"
},
{
"comment": "v1.2.1",