Skip to content

Commit

Permalink
edit can now be used to insert passwords
Browse files Browse the repository at this point in the history
aviau committed Feb 21, 2018
1 parent 301dd04 commit 365b5bc
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions cmd/gopass/internal/cli/command/edit/edit.go
Original file line number Diff line number Diff line change
@@ -52,10 +52,16 @@ func ExecEdit(cfg command.Config, args []string) error {

passname := fs.Arg(0)

password, err := store.GetPassword(passname)

if err != nil {
return err
action := "inserted"

password := ""
if containsPasword, _ := store.ContainsPassword(passname); containsPasword {
var err error
password, err = store.GetPassword(passname)
if err != nil {
return err
}
action = "edited"
}

file, _ := ioutil.TempFile(os.TempDir(), "gopass")
@@ -76,6 +82,6 @@ func ExecEdit(cfg command.Config, args []string) error {
return err
}

fmt.Fprintf(cfg.WriterOutput(), "Succesfully edited password \"%s\".\n", passname)
fmt.Fprintf(cfg.WriterOutput(), "Succesfully %s password \"%s\".\n", action, passname)
return nil
}
2 changes: 1 addition & 1 deletion man/gopass.1
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ before overwriting an existing password, unless \fI--force\fP or \fI-f\fP is spe
command is alternatively named \fBadd\fP.
.TP
\fBedit\fP \fIpass-name\fP
Edit an existing password using the default text editor specified
Insert a new password or edit an existing password using the default text editor specified
by the environment variable \fIEDITOR\fP or using
.BR editor
as a fallback. This mode makes use of temporary files for editing.

0 comments on commit 365b5bc

Please sign in to comment.