2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-26 20:30:19 +00:00

Add password successful feedback

This adds some feedback when entering the password on the command line.
When the password is entered and supplied through stdin (and stdout is a
terminal) then the a message saying `password is correct` if correct is
printed.
This commit is contained in:
Anton Lindstrom 2017-10-04 13:45:05 +02:00
parent eb59d28154
commit 55e6003749

View File

@ -132,6 +132,20 @@ func restoreTerminal() {
})
}
// shouldOutputPasswordSuccessful returns true if the password is supplied
// interactively and the stdout is a terminal.
func shouldOutputPasswordSuccessful() bool {
if globalOptions.PasswordFile != "" {
return false
}
if os.Getenv("RESTIC_PASSWORD") != "" {
return false
}
return stdoutIsTerminal()
}
// ClearLine creates a platform dependent string to clear the current
// line, so it can be overwritten. ANSI sequences are not supported on
// current windows cmd shell.
@ -326,6 +340,10 @@ func OpenRepository(opts GlobalOptions) (*repository.Repository, error) {
return nil, err
}
if shouldOutputPasswordSuccessful() {
Verbosef("password is correct\n")
}
if opts.NoCache {
return s, nil
}