Address JetBrains warnings

This commit is contained in:
2025-05-29 22:05:57 -04:00
parent 16aaa4f330
commit a1c47b06a1
10 changed files with 88 additions and 33 deletions
+4 -1
View File
@@ -26,7 +26,10 @@ func clipClearProcess(assignedContents string) error {
// if assignedContents is empty, clear the clipboard immediately and unconditionally
if assignedContents == "" {
clearClipboard()
err := clearClipboard()
if err != nil {
return err
}
return nil
}
+11 -4
View File
@@ -52,7 +52,10 @@ func CopyArgument(targetLocation string, field int) error {
if err != nil {
return err
}
copyString(true, token)
err = copyString(true, token)
if err != nil {
return err
}
// sleep until next 30-second interval
time.Sleep(time.Duration(30-(currentTime.Second()%30)) * time.Second)
}
@@ -62,18 +65,22 @@ func CopyArgument(targetLocation string, field int) error {
}
// copy field to clipboard, launch clipboard clearing process
copyString(false, copySubject)
err = copyString(false, copySubject)
if err != nil {
return err
}
}
return nil
}
// ClipClearArgument reads the assigned clipboard contents from stdin and passes them to clipClearProcess.
func ClipClearArgument() {
func ClipClearArgument() error {
assignedContents := back.ReadFromStdin()
if assignedContents == "" {
os.Exit(0) // use os.Exit instead of core.Exit, as this function runs out of a background subprocess that is invisible to the user (will never appear in GUI/TUI environment)
}
clipClearProcess(assignedContents)
err := clipClearProcess(assignedContents)
return err
}
// GenTOTP generates a TOTP token from a secret (supports standard and Steam TOTP).
+17 -5
View File
@@ -14,7 +14,7 @@ import (
)
// LibmuttonInit creates the libmutton config structure based on user input.
// rcwPassphrase and clientSpecificIniData are cab be left blank if not needed.
// rcwPassphrase and clientSpecificIniData can be left blank if not needed.
func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][3]string, rcwPassphrase []byte, preserveOldConfigDir bool) error {
r := strings.ToLower(inputCB("Configure SSH settings (for synchronization)? (y/N)"))
if len(r) > 0 && r[0] == 'y' {
@@ -44,7 +44,7 @@ func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][
}
//// write config file
//// temporarily assign sshEntryRoot and sshIsWindows to null to pass initial device ID registration
cfg.WriteConfig(append(
err = cfg.WriteConfig(append(
clientSpecificIniData,
[][3]string{
{"LIBMUTTON", "sshUser", sshUser},
@@ -54,18 +54,30 @@ func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][
{"LIBMUTTON", "sshKeyProtected", strconv.FormatBool(sshKeyProtected)},
{"LIBMUTTON", "sshEntryRoot", "null"},
{"LIBMUTTON", "sshIsWindows", "false"}}...), nil, false)
if err != nil {
return errors.New("unable to write config file: " + err.Error())
}
// generate and register device ID
sshEntryRoot, sshIsWindows, err := synccycles.DeviceIDGen(oldDeviceID)
if err != nil {
return errors.New("unable to generate device ID: " + err.Error())
}
cfg.WriteConfig([][3]string{{"LIBMUTTON", "sshEntryRoot", sshEntryRoot}, {"LIBMUTTON", "sshIsWindows", sshIsWindows}}, nil, true)
err = cfg.WriteConfig([][3]string{{"LIBMUTTON", "sshEntryRoot", sshEntryRoot}, {"LIBMUTTON", "sshIsWindows", sshIsWindows}}, nil, true)
if err != nil {
return errors.New("unable to write config file: " + err.Error())
}
} else {
// initialize libmutton directories
global.DirInit(preserveOldConfigDir)
_, err := global.DirInit(preserveOldConfigDir)
if err != nil {
return errors.New("unable to initialize libmutton directories: " + err.Error())
}
// write config file
if len(clientSpecificIniData) > 0 { // TODO test passing empty clientSpecificIniData
cfg.WriteConfig(clientSpecificIniData, nil, false)
err = cfg.WriteConfig(clientSpecificIniData, nil, false)
if err != nil {
return errors.New("unable to write config file: " + err.Error())
}
}
}
// generate rcw sanity check file (if requested)
+1 -1
View File
@@ -15,6 +15,6 @@ import (
func LaunchClipClearProcess(copySubject string, isWayland bool) {
cmd := exec.Command(os.Args[0], "clipclear", strconv.FormatBool(isWayland))
back.WriteToStdin(cmd, copySubject)
cmd.Start()
_ = cmd.Start()
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
}