mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-02 23:27:26 -04:00
Fix printing full executable path in error messages on Windows
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package sync
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var vanityEXE = os.Args[0]
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package sync
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var vanityEXE = os.Args[0][strings.LastIndex(os.Args[0], "\\")+1:]
|
||||||
+2
-2
@@ -26,7 +26,7 @@ func getSSHClient(manualSync bool) (*ssh.Client, string, bool) {
|
|||||||
var sshUserConfig []string
|
var sshUserConfig []string
|
||||||
var missingValueError string
|
var missingValueError string
|
||||||
if manualSync {
|
if manualSync {
|
||||||
missingValueError = "SSH settings not configured - run \"" + os.Args[0] + " init\" to configure"
|
missingValueError = "SSH settings not configured - run \"" + vanityEXE + " init\" to configure"
|
||||||
} else {
|
} else {
|
||||||
missingValueError = "0"
|
missingValueError = "0"
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ func getRemoteDataFromClient(manualSync bool) (map[string]int64, []string, []str
|
|||||||
clientDeviceID, _ := os.ReadDir(backend.ConfigDir + backend.PathSeparator + "devices")
|
clientDeviceID, _ := os.ReadDir(backend.ConfigDir + backend.PathSeparator + "devices")
|
||||||
if len(clientDeviceID) == 0 {
|
if len(clientDeviceID) == 0 {
|
||||||
if manualSync {
|
if manualSync {
|
||||||
fmt.Println(backend.AnsiError + "Sync failed - No device ID found; run \"" + os.Args[0] + " init\" to generate a device ID" + backend.AnsiReset)
|
fmt.Println(backend.AnsiError + "Sync failed - No device ID found; run \"" + vanityEXE + " init\" to generate a device ID" + backend.AnsiReset)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
} else {
|
} else {
|
||||||
backend.Exit(0) // exit silently if the sync job was called automatically, as the user may just be in offline mode
|
backend.Exit(0) // exit silently if the sync job was called automatically, as the user may just be in offline mode
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func WalkEntryDir() ([]string, []string) {
|
|||||||
// check for errors encountered while walking directory
|
// check for errors encountered while walking directory
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
fmt.Println(backend.AnsiError+"The entry directory does not exist - run \""+os.Args[0], "init"+"\" to create it"+backend.AnsiReset)
|
fmt.Println(backend.AnsiError+"The entry directory does not exist - run \""+vanityEXE, "init"+"\" to create it"+backend.AnsiReset)
|
||||||
} else {
|
} else {
|
||||||
// otherwise, print the source of the error
|
// otherwise, print the source of the error
|
||||||
fmt.Println(backend.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + backend.AnsiReset)
|
fmt.Println(backend.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + backend.AnsiReset)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func WalkEntryDir() ([]string, []string) {
|
|||||||
// check for errors encountered while walking directory
|
// check for errors encountered while walking directory
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
fmt.Println(backend.AnsiError+"The entry directory does not exist - run \""+os.Args[0], "init"+"\" to create it"+backend.AnsiReset)
|
fmt.Println(backend.AnsiError+"The entry directory does not exist - run \""+vanityEXE, "init"+"\" to create it"+backend.AnsiReset)
|
||||||
} else {
|
} else {
|
||||||
// otherwise, print the source of the error
|
// otherwise, print the source of the error
|
||||||
fmt.Println(backend.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + backend.AnsiReset)
|
fmt.Println(backend.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + backend.AnsiReset)
|
||||||
|
|||||||
Reference in New Issue
Block a user