Closed Theaxiom closed 6 years ago
Would you mind tweaking this code?
On Apr 20, 2017 10:11 PM, "Chris Aubuchon" notifications@github.com wrote:
@ChrisAubuchon commented on this pull request.
In commands/commands.go https://github.com/mantl/consul-cli/pull/47#discussion_r112610039:
+} + +func CheckConsulFile(inputFile string) string {
- tempConsulFile := inputFile
- if inputFile[:2] == "~/" {
- user, _ := user.Current()
- homeDir := fmt.Sprint(user.HomeDir + "/")
- tempConsulFile = strings.Replace(inputFile, "~/", homeDir, 1)
- }
- _, err := os.Stat(tempConsulFile)
- if err == nil {
- return tempConsulFile
- }
- return "" +}
Might want to look at https://github.com/mitchellh/go-homedir for homedir detection. Biggest benefit is that it works in windows as well.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mantl/consul-cli/pull/47#pullrequestreview-33938408, or mute the thread https://github.com/notifications/unsubscribe-auth/AADetVZNKbuDG2BjVt_ITDZ5IJbTee1_ks5ryDqSgaJpZM4ND1f0 .
Yeah. I'll run with it. It's a cool idea.
Awesome, thanks.
On Apr 20, 2017 10:13 PM, "Chris Aubuchon" notifications@github.com wrote:
Yeah. I'll run with it. It's a cool idea.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mantl/consul-cli/pull/47#issuecomment-296069168, or mute the thread https://github.com/notifications/unsubscribe-auth/AADetQfVBcjFGpheoemYx_SGwS44VfsUks5ryDr3gaJpZM4ND1f0 .
I was just pulling this in from a fork because it looked useful, do what you will with it. 😀
On Apr 20, 2017 10:10 PM, "Chris Aubuchon" notifications@github.com wrote: