mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-03 23:57:23 -04:00
Make use of libmutton's new core.PrintError utility function
This commit is contained in:
@@ -5,7 +5,7 @@ go 1.23.4
|
|||||||
require (
|
require (
|
||||||
github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514
|
github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514
|
||||||
github.com/charmbracelet/glamour v0.7.0
|
github.com/charmbracelet/glamour v0.7.0
|
||||||
github.com/rwinkhart/libmutton v0.2.5-0.20250126231254-eb2b349697ed
|
github.com/rwinkhart/libmutton v0.2.5-0.20250202014803-e9d0c3704362
|
||||||
golang.org/x/term v0.28.0
|
golang.org/x/term v0.28.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
|||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/rwinkhart/convertroman v0.2.0 h1:otUm939eXT77q/Lr31mJtMwVWEw0RjEUB71gO65h9OM=
|
github.com/rwinkhart/convertroman v0.2.0 h1:otUm939eXT77q/Lr31mJtMwVWEw0RjEUB71gO65h9OM=
|
||||||
github.com/rwinkhart/convertroman v0.2.0/go.mod h1:Af6HqvX0EIM4Y3HcnNXbbRey1dLasGB7WU0+3Cowgmw=
|
github.com/rwinkhart/convertroman v0.2.0/go.mod h1:Af6HqvX0EIM4Y3HcnNXbbRey1dLasGB7WU0+3Cowgmw=
|
||||||
github.com/rwinkhart/libmutton v0.2.5-0.20250126231254-eb2b349697ed h1:MNCsowWbcO0okuRNF3VDQ/quNju0CUU8shUCzIxQGsk=
|
github.com/rwinkhart/libmutton v0.2.5-0.20250202014803-e9d0c3704362 h1:9D8OqhGvh/f7l6z/owPwwgV9FS5SbLCa+CJfnyi27S4=
|
||||||
github.com/rwinkhart/libmutton v0.2.5-0.20250126231254-eb2b349697ed/go.mod h1:kn7x0901qFyX1/HBxJf287zoySZkxKRMObKigLiI5Ok=
|
github.com/rwinkhart/libmutton v0.2.5-0.20250202014803-e9d0c3704362/go.mod h1:kn7x0901qFyX1/HBxJf287zoySZkxKRMObKigLiI5Ok=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -164,8 +163,7 @@ func main() {
|
|||||||
case "init":
|
case "init":
|
||||||
cli.TempInitCli()
|
cli.TempInitCli()
|
||||||
case "tweak":
|
case "tweak":
|
||||||
fmt.Println(core.AnsiError + "\"tweak\" is not yet implemented" + core.AnsiReset)
|
core.PrintError("\"tweak\" is not yet implemented", 0, true)
|
||||||
os.Exit(0)
|
|
||||||
case "copy":
|
case "copy":
|
||||||
cli.HelpCopy()
|
cli.HelpCopy()
|
||||||
case "edit":
|
case "edit":
|
||||||
|
|||||||
+1
-4
@@ -1,8 +1,6 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/core"
|
||||||
@@ -14,8 +12,7 @@ func AddEntry(targetLocation string, hideSecrets bool, entryType uint8) {
|
|||||||
// ensure target location does not already exist
|
// ensure target location does not already exist
|
||||||
_, isAccessible := core.TargetIsFile(targetLocation, false, 0)
|
_, isAccessible := core.TargetIsFile(targetLocation, false, 0)
|
||||||
if isAccessible {
|
if isAccessible {
|
||||||
fmt.Println(core.AnsiError + "Target location already exists" + core.AnsiReset)
|
core.PrintError("Target location already exists", core.ErrorTargetExists, true)
|
||||||
os.Exit(core.ErrorTargetExists)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure target containing directory exists and is a directory (not a file)
|
// ensure target containing directory exists and is a directory (not a file)
|
||||||
|
|||||||
+1
-3
@@ -2,7 +2,6 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -43,8 +42,7 @@ func EditEntryField(targetLocation string, hideSecrets bool, field int) {
|
|||||||
// edit the note
|
// edit the note
|
||||||
editedNote, noteEdited := editNote(noteData)
|
editedNote, noteEdited := editNote(noteData)
|
||||||
if !noteEdited { // exit early if the note was not edited
|
if !noteEdited { // exit early if the note was not edited
|
||||||
fmt.Println(core.AnsiError + "Entry is unchanged" + core.AnsiReset)
|
core.PrintError("Entry is unchanged", 0, true)
|
||||||
os.Exit(0)
|
|
||||||
}
|
}
|
||||||
unencryptedEntry = append(nonNoteData, editedNote...)
|
unencryptedEntry = append(nonNoteData, editedNote...)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -21,8 +21,7 @@ func TempInitCli() {
|
|||||||
uidSlice := core.GpgUIDListGen()
|
uidSlice := core.GpgUIDListGen()
|
||||||
gpgIDInt := inputMenuGen("Select GPG key:", uidSlice)
|
gpgIDInt := inputMenuGen("Select GPG key:", uidSlice)
|
||||||
if gpgIDInt == 0 {
|
if gpgIDInt == 0 {
|
||||||
fmt.Println(core.AnsiError + "No GPG keys found - please generate one" + core.AnsiReset)
|
core.PrintError("No GPG keys found - please generate one", core.ErrorTargetNotFound, true)
|
||||||
os.Exit(core.ErrorTargetNotFound)
|
|
||||||
}
|
}
|
||||||
gpgID = uidSlice[gpgIDInt-1]
|
gpgID = uidSlice[gpgIDInt-1]
|
||||||
}
|
}
|
||||||
@@ -47,7 +46,7 @@ func TempInitCli() {
|
|||||||
sshKey = cmp.Or(core.ExpandPathWithHome(input("SSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
|
sshKey = cmp.Or(core.ExpandPathWithHome(input("SSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
|
||||||
sshKeyIsFile, _ = core.TargetIsFile(sshKey, false, 0)
|
sshKeyIsFile, _ = core.TargetIsFile(sshKey, false, 0)
|
||||||
if !sshKeyIsFile {
|
if !sshKeyIsFile {
|
||||||
fmt.Println(core.AnsiError+"SSH identity file not found:", sshKey+core.AnsiReset)
|
fmt.Println(core.AnsiError+"SSH identity file not found:", sshKey+core.AnsiReset) // do not exit after error (allow user to retry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hideSecrets
|
|||||||
fmt.Println(AnsiBold + "\nEntry Preview:" + core.AnsiReset)
|
fmt.Println(AnsiBold + "\nEntry Preview:" + core.AnsiReset)
|
||||||
EntryReader(unencryptedEntry, hideSecrets, true)
|
EntryReader(unencryptedEntry, hideSecrets, true)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(core.AnsiError + "No data supplied for entry" + core.AnsiReset)
|
core.PrintError("No data supplied for entry", core.ErrorTargetNotFound, true)
|
||||||
os.Exit(core.ErrorTargetNotFound)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user