diff --git a/lib/install.go b/lib/install.go index 990cea7..b674bd4 100644 --- a/lib/install.go +++ b/lib/install.go @@ -52,7 +52,11 @@ func init() { } //Install : Install the provided version in the argument -func Install(url string, appversion string, assests []modal.Repo) string { +func Install(url string, appversion string, assests []modal.Repo, userBinPath * string) string { + /* If user provided bin path use user one instead of default */ + if userBinPath != nil { + installedBinPath = *userBinPath + } /* check if selected version already downloaded */ fileExist := CheckFileExist(installLocation + installVersion + appversion) diff --git a/main.go b/main.go index 7cdbd3b..e6a3381 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,7 @@ func main() { client.ClientID = CLIENT_ID client.ClientSecret = CLIENT_SECRET + userBinPath := getopt.StringLong("bin", 'b', "Custom binary path. For example: /Users/username/bin/terragrunt") versionFlag := getopt.BoolLong("version", 'v', "displays the version of tgswitch") helpFlag := getopt.BoolLong("help", 'h', "displays help message") _ = versionFlag @@ -67,7 +68,7 @@ func main() { exist := lib.VersionExist(requestedVersion, tflist) if exist { - installLocation := lib.Install(terragruntURL, requestedVersion, assets) + installLocation := lib.Install(terragruntURL, requestedVersion, assets, userBinPath) lib.AddRecent(requestedVersion, installLocation) //add to recent file for faster lookup } else { fmt.Println("Not a valid terragrunt version") @@ -99,7 +100,7 @@ func main() { os.Exit(1) } - installLocation := lib.Install(terragruntURL, tgversion, assets) + installLocation := lib.Install(terragruntURL, tgversion, assets, userBinPath) lib.AddRecent(tgversion, installLocation) //add to recent file for faster lookup os.Exit(0) } else {