mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Make use of libmutton's new core.PrintError utility function
This commit is contained in:
+1
-4
@@ -1,8 +1,6 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/rwinkhart/libmutton/core"
|
||||
@@ -14,8 +12,7 @@ func AddEntry(targetLocation string, hideSecrets bool, entryType uint8) {
|
||||
// ensure target location does not already exist
|
||||
_, isAccessible := core.TargetIsFile(targetLocation, false, 0)
|
||||
if isAccessible {
|
||||
fmt.Println(core.AnsiError + "Target location already exists" + core.AnsiReset)
|
||||
os.Exit(core.ErrorTargetExists)
|
||||
core.PrintError("Target location already exists", core.ErrorTargetExists, true)
|
||||
}
|
||||
|
||||
// ensure target containing directory exists and is a directory (not a file)
|
||||
|
||||
+1
-3
@@ -2,7 +2,6 @@ package cli
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
@@ -43,8 +42,7 @@ func EditEntryField(targetLocation string, hideSecrets bool, field int) {
|
||||
// edit the note
|
||||
editedNote, noteEdited := editNote(noteData)
|
||||
if !noteEdited { // exit early if the note was not edited
|
||||
fmt.Println(core.AnsiError + "Entry is unchanged" + core.AnsiReset)
|
||||
os.Exit(0)
|
||||
core.PrintError("Entry is unchanged", 0, true)
|
||||
}
|
||||
unencryptedEntry = append(nonNoteData, editedNote...)
|
||||
}
|
||||
|
||||
+2
-3
@@ -21,8 +21,7 @@ func TempInitCli() {
|
||||
uidSlice := core.GpgUIDListGen()
|
||||
gpgIDInt := inputMenuGen("Select GPG key:", uidSlice)
|
||||
if gpgIDInt == 0 {
|
||||
fmt.Println(core.AnsiError + "No GPG keys found - please generate one" + core.AnsiReset)
|
||||
os.Exit(core.ErrorTargetNotFound)
|
||||
core.PrintError("No GPG keys found - please generate one", core.ErrorTargetNotFound, true)
|
||||
}
|
||||
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)
|
||||
sshKeyIsFile, _ = core.TargetIsFile(sshKey, false, 0)
|
||||
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)
|
||||
EntryReader(unencryptedEntry, hideSecrets, true)
|
||||
} else {
|
||||
fmt.Println(core.AnsiError + "No data supplied for entry" + core.AnsiReset)
|
||||
os.Exit(core.ErrorTargetNotFound)
|
||||
core.PrintError("No data supplied for entry", core.ErrorTargetNotFound, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user