Bump go-boilerplate; make error codes sequential

This commit is contained in:
2025-06-01 14:17:51 -04:00
parent 2e3be57e3e
commit 5f8789a0f0
12 changed files with 26 additions and 21 deletions
+4 -1
View File
@@ -15,7 +15,10 @@ import (
// CopyArgument copies a field from an entry to the clipboard.
func CopyArgument(targetLocation string, field int) error {
if isFile, _ := back.TargetIsFile(targetLocation, true, 2); isFile {
if isFile, _, err := back.TargetIsFile(targetLocation, true, 2); isFile {
if err != nil {
return err
}
decryptedEntry, err := crypt.DecryptFileToSlice(targetLocation)
if err != nil {
+1 -1
View File
@@ -21,7 +21,7 @@ func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][
// ensure ssh key file exists
fallbackSSHKey := back.Home + global.PathSeparator + ".ssh" + global.PathSeparator + "id_ed25519"
sshKeyPath := cmp.Or(back.ExpandPathWithHome(inputCB(back.AnsiBold+"Note:"+back.AnsiReset+" Only key-based authentication is supported (keys may optionally be passphrase-protected).\n The remote server must already be in your ~"+global.PathSeparator+".ssh"+global.PathSeparator+"known_hosts file.\n\nSSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
sshKeyIsFile, _ := back.TargetIsFile(sshKeyPath, false, 0)
sshKeyIsFile, _, _ := back.TargetIsFile(sshKeyPath, false, 0) // error is ignored because errorOnFail is false
if !sshKeyIsFile {
return errors.New("SSH identity file not found: " + sshKeyPath)
}
+2 -2
View File
@@ -13,7 +13,7 @@ import (
// For non-interactive CLI implementations, an entirely separate process is created for this purpose.
func LaunchClipClearProcess(copySubject string) {
cmd := exec.Command(os.Args[0], "clipclear")
back.WriteToStdin(cmd, copySubject)
cmd.Start()
_ = back.WriteToStdin(cmd, copySubject)
_ = cmd.Start()
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
}
+1 -1
View File
@@ -14,7 +14,7 @@ import (
// For non-interactive CLI implementations, an entirely separate process is created for this purpose.
func LaunchClipClearProcess(copySubject string, isWayland bool) {
cmd := exec.Command(os.Args[0], "clipclear", strconv.FormatBool(isWayland))
back.WriteToStdin(cmd, copySubject)
_ = back.WriteToStdin(cmd, copySubject)
_ = cmd.Start()
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
}
+2 -2
View File
@@ -156,13 +156,13 @@ func ClampTrailingWhitespace(note []string) {
// Returns: statusCode (0 = success, 1 = target location already exists, 2 = containing directory is invalid).
func EntryAddPrecheck(targetLocation string) (uint8, error) {
// ensure target location does not already exist
_, isAccessible := back.TargetIsFile(targetLocation, false, 0)
_, isAccessible, _ := back.TargetIsFile(targetLocation, false, 0) // error is ignored because errorOnFail is false
if isAccessible {
return 1, errors.New("target location already exists")
}
// ensure target containing directory exists and is a directory (not a file)
containingDir := targetLocation[:strings.LastIndex(targetLocation, global.PathSeparator)]
isFile, isAccessible := back.TargetIsFile(containingDir, false, 1)
isFile, isAccessible, _ := back.TargetIsFile(containingDir, false, 1) // error is ignored because errorOnFail is false
if isFile || !isAccessible {
return 2, errors.New("\"" + containingDir + "\" is not a valid containing directory")
}