Skip to content

Commit

Permalink
generate: prompt before overwriting
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Jul 18, 2017
1 parent 7691bc5 commit 2c37138
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ This new command should connect to a server using an encrypted rsa key.
- [ ] ``--clip, -c``
- [ ] ``--in-place, -i``
- [X] ``--force, -f``
- [ ] Prompt before overwriting an existing password, unless --force or -f is specified.
- [X] Prompt before overwriting an existing password, unless --force or -f is specified.
5 changes: 2 additions & 3 deletions cmd/gopass/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,8 @@ func execGenerate(cmd *commandLine, args []string) error {

store := getStore(cmd)

if containsPassword, _ := store.ContainsPassword(passName); containsPassword {
if !force {
fmt.Fprintf(cmd.WriterOutput, "Error: '%s' already exists. Use -f to override.\n", passName)
if containsPassword, _ := store.ContainsPassword(passName); containsPassword && !force {
if !gopass_terminal.AskYesNo(cmd.WriterOutput, fmt.Sprintf("Password '%s' already esists. Would you like to overwrite? [y/n] ", passName)) {
return nil
}
}
Expand Down

0 comments on commit 2c37138

Please sign in to comment.