From 118ffc2adbec1f47551281fadf9eab477444799f Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Thu, 16 Jan 2025 14:26:57 -0500 Subject: [PATCH] Move expandPathWithHome to libmutton --- go.mod | 2 +- go.sum | 4 ++-- src/cli/init.go | 2 +- src/cli/utilitiesMisc.go | 5 ----- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index fa1f921..118e974 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.4 require ( github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514 github.com/charmbracelet/glamour v0.7.0 - github.com/rwinkhart/libmutton v0.2.5-0.20250116184730-89b74cec1e01 + github.com/rwinkhart/libmutton v0.2.5-0.20250116192207-81b78068a75a golang.org/x/term v0.28.0 ) diff --git a/go.sum b/go.sum index 5090409..bb1d390 100644 --- a/go.sum +++ b/go.sum @@ -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/rwinkhart/convertroman v0.2.0 h1:otUm939eXT77q/Lr31mJtMwVWEw0RjEUB71gO65h9OM= github.com/rwinkhart/convertroman v0.2.0/go.mod h1:Af6HqvX0EIM4Y3HcnNXbbRey1dLasGB7WU0+3Cowgmw= -github.com/rwinkhart/libmutton v0.2.5-0.20250116184730-89b74cec1e01 h1:+1S0VkBSMhYYyr0L7ukFni7uxJhbas19bk2TsMd+qj0= -github.com/rwinkhart/libmutton v0.2.5-0.20250116184730-89b74cec1e01/go.mod h1:kn7x0901qFyX1/HBxJf287zoySZkxKRMObKigLiI5Ok= +github.com/rwinkhart/libmutton v0.2.5-0.20250116192207-81b78068a75a h1:sN7Vq8j3AKUDIB3E1WOwSnZWWacuIJkvbWSVEOIRg0U= +github.com/rwinkhart/libmutton v0.2.5-0.20250116192207-81b78068a75a/go.mod h1:kn7x0901qFyX1/HBxJf287zoySZkxKRMObKigLiI5Ok= 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/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/src/cli/init.go b/src/cli/init.go index 767a216..de4a65e 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -44,7 +44,7 @@ func TempInitCli() { var sshKeyIsFile bool for !sshKeyIsFile { fallbackSSHKey := core.Home + core.PathSeparator + ".ssh" + core.PathSeparator + "id_ed25519" - sshKey = cmp.Or(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) if !sshKeyIsFile { fmt.Println(core.AnsiError+"SSH identity file not found:", sshKey+core.AnsiReset) diff --git a/src/cli/utilitiesMisc.go b/src/cli/utilitiesMisc.go index 633d617..39f70a1 100644 --- a/src/cli/utilitiesMisc.go +++ b/src/cli/utilitiesMisc.go @@ -78,11 +78,6 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hideSecrets } } -// expandPathWithHome, given a path (as a string) containing "~", returns the path with "~" expanded to the user's home directory. -func expandPathWithHome(path string) string { - return strings.Replace(path, "~", core.Home, 1) -} - // RunJobWrapper is a wrapper for sync.RunJob that sets the passphrase input function to inputHidden. func RunJobWrapper(manualSync bool) { core.PassphraseInputFunction = inputHidden