commit 4debe5e052b9d17b94540db001718d7cbbc40ee5
parent de4e62f15af731ebe603b3924d567d71a88c5c2a
Author: Sean Enck <sean@ttypty.com>
Date: Sun, 2 Oct 2022 11:00:40 -0400
mv is completed
Diffstat:
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/cmd/main.go b/cmd/main.go
@@ -30,13 +30,6 @@ type (
}
)
-func getEntry(args []string, idx int) string {
- if len(args) != idx+1 {
- exit("invalid entry given", errors.New("specific entry required"))
- }
- return args[idx]
-}
-
func internalCallback(name string) callbackFunction {
switch name {
case "totp":
@@ -102,8 +95,8 @@ func run() *programError {
if len(args) != 4 {
return newError("mv requires src and dst", errors.New("src/dst required"))
}
- src := getEntry(args, 2)
- dst := getEntry(args, 3)
+ src := args[2]
+ dst := args[3]
srcExists, err := t.Get(src, backend.SecretValue)
if err != nil {
return newError("unable to get source object", errors.New("failed to get source"))
@@ -120,6 +113,9 @@ func run() *programError {
return nil
}
}
+ if err := t.Move(*srcExists, dst); err != nil {
+ return newError("unable to move object", err)
+ }
case "insert":
options := cli.Arguments{}
idx := 2
@@ -137,7 +133,7 @@ func run() *programError {
return newError("too many arguments", errors.New("insert can only perform one operation"))
}
isPipe := inputs.IsInputFromPipe()
- entry := getEntry(args, idx)
+ entry := args[idx]
existing, err := t.Get(entry, backend.BlankValue)
if err != nil {
return newError("unable to find an exact, existing match", err)
@@ -159,7 +155,7 @@ func run() *programError {
}
fmt.Println("")
case "rm":
- deleting := getEntry(args, 2)
+ deleting := args[2]
existing, err := t.Get(deleting, backend.BlankValue)
if err != nil {
return newError("unable to get entity to delete", err)
@@ -171,7 +167,7 @@ func run() *programError {
}
case "show", "clip":
- entry := getEntry(args, 2)
+ entry := args[2]
clipboard := platform.Clipboard{}
isShow := command == "show"
if !isShow {
diff --git a/tests/expected.log b/tests/expected.log
@@ -32,5 +32,7 @@ delete entry? (y/N)
delete entry? (y/N)
delete entry? (y/N) unable to remove entry (entity is empty/invalid)
+keys/k/one2
+keyx/d/e
delete entry? (y/N)
keys/k/one2
diff --git a/tests/run.sh b/tests/run.sh
@@ -34,7 +34,9 @@ _run() {
echo
yes 2>/dev/null | "$BIN/lb" rm test/k/one
echo
- yes 2>/dev/null | "$BIN/lb" rm key/a/one
+ "$BIN/lb" mv key/a/one keyx/d/e
+ "$BIN/lb" ls
+ yes 2>/dev/null | "$BIN/lb" rm keyx/d/e
echo
"$BIN/lb" ls
}