You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnexit.Error(exit.Usage, nil, "Cannot remove %q: Is a directory. Use 'gopass rm -r %s' to delete", name, name)
26
34
}
27
35
28
36
// specifying a key is optional.
29
37
key:=c.Args().Get(1)
30
38
31
-
ifrecursive&&key!="" {
32
-
returnexit.Error(exit.Usage, nil, "Can not use -r with a key. Invoke delete either with a key or with -r")
39
+
// multiple secrets, so not a key
40
+
iflen(c.Args().Tail()) >1 {
41
+
key=""
42
+
}
43
+
44
+
names:=append([]string{name}, c.Args().Tail()...)
45
+
46
+
ifkey!=""&&s.Store.Exists(ctx, key) {
47
+
returnexit.Error(exit.Unsupported, nil, "Ambiguous key %q, use 'gopass edit %s' to delete", key, name)
48
+
}
49
+
50
+
if!s.Store.Exists(ctx, name) {
51
+
returnexit.Error(exit.NotFound, nil, "Secret %q does not exist", name)
33
52
}
34
53
35
54
if!c.Bool("force") { // don't check if it's force anyway.
36
-
recStr:=""
37
-
ifrecursive {
38
-
recStr="recursively "
55
+
qStr:=fmt.Sprintf("☠ Are you sure you would like to delete %q?", names)
56
+
ifkey!="" {
57
+
qStr=fmt.Sprintf("☠ Are you sure you would like to delete %q from %q?", key, name)
39
58
}
40
-
if (s.Store.Exists(ctx, name) ||s.Store.IsDir(ctx, name)) &&key==""&&!termio.AskForConfirmation(ctx, fmt.Sprintf("☠ Are you sure you would like to %sdelete %s?", recStr, name)) {
59
+
if (s.Store.Exists(ctx, name) ||s.Store.IsDir(ctx, name)) &&key==""&&!termio.AskForConfirmation(ctx, qStr) {
41
60
returnnil
42
61
}
43
62
}
44
63
45
-
ifrecursive&&key=="" {
46
-
debug.Log("pruning %q", name)
47
-
iferr:=s.Store.Prune(ctx, name); err!=nil {
48
-
returnexit.Error(exit.Unknown, err, "failed to prune %q: %s", name, err)
49
-
}
50
-
debug.Log("pruned %q", name)
51
-
52
-
returnnil
53
-
}
54
-
55
64
// deletes a single key from a YAML doc.
56
65
ifkey!="" {
57
66
debug.Log("removing key %q from %q", key, name)
58
67
59
68
returns.deleteKeyFromYAML(ctx, name, key)
60
69
}
61
70
62
-
debug.Log("removing entry %q", name)
63
-
iferr:=s.Store.Delete(ctx, name); err!=nil {
64
-
returnexit.Error(exit.IO, err, "Can not delete %q: %s", name, err)
71
+
for_, name:=rangenames {
72
+
debug.Log("removing entry %q", name)
73
+
iferr:=s.Store.Delete(ctx, name); err!=nil {
74
+
returnexit.Error(exit.IO, err, "Can not delete %q: %s", name, err)
if (s.Store.Exists(ctx, name) ||s.Store.IsDir(ctx, name)) &&!termio.AskForConfirmation(ctx, fmt.Sprintf("☠ Are you sure you would like to recursively delete %q?", name)) {
84
+
returnnil
85
+
}
86
+
}
87
+
88
+
debug.Log("pruning %q", name)
89
+
iferr:=s.Store.Prune(ctx, name); err!=nil {
90
+
returnexit.Error(exit.Unknown, err, "failed to prune %q: %s", name, err)
0 commit comments